fp-errors
Stop throwing everywhere - handle errors as values using Either and TaskEither for cleaner, more predictable code
npx skills add sickn33/agentic-awesome-skills --skill fp-errors --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
What it does
The skill teaches turning errors into data by using fp-ts Either and TaskEither instead of exceptions. It shows how to replace try/catch spaghetti with functions that return Either, enabling explicit error handling and safer composition. It covers the core patterns for the Result type (Either), chaining operations, collecting multiple errors, and async operations via TaskEither. It also includes guidance on converting between patterns (Nullable, Throwing, Promise) and demonstrates practical scenarios like input parsing, form validation, and parallel async data fetching.
How it works
- Introduces returning Either<E, A> from functions to signal failure or success, instead of throwing. Example functions return Left(error) or Right(value).
- Demonstrates transforming and handling Either values with pattern matching, map, mapLeft, getOrElse, and fold to produce outputs based on success or failure.
- Shows chaining with E.chain to propagate the first error in a sequence of dependent operations, including Do-notation style bindings for readability.
- Explains collecting multiple errors using an Applicative Validation instance (E.getApplicativeValidation with NEA.getSemigroup) and sequenceS to accumulate errors from independent validations.
- Covers asynchronous workflows using TaskEither for lazy, promise-based computations, including TE.tryCatch, TE.chain, and TE.fold for handling results.
- Details converting from nullable, throwing, and promise patterns to fp-ts equivalents and back.
When to use it
- Use Either or TaskEither to replace exception-heavy code
- When tasks involve validation, domain errors, or clearer error contracts in TypeScript
- When you want practical fp-ts error-handling guidance for real application code
What it can touch
- Functions and code examples reference fp-ts: "fp-ts/Either", "fp-ts/TaskEither", and utility imports like
pipefrom "fp-ts/function". - Tools named exactly as in the skill: "E.right", "E.left", "TE.tryCatch", "TE.chain", "sequenceS", "pipe".
Caveats
- The material emphasizes functional error handling patterns and may require familiarity with fp-ts concepts like Either, TaskEither, and NonEmptyArray for advanced validation scenarios.
- It uses TypeScript-specific types and imports; correctness depends on fp-ts version compatibility as shown in examples.
# Practical Error Handling with fp-ts This skill teaches you how to handle errors without try/catch spaghetti. No academic jargon - just practical patterns for real problems. The core idea: **Errors are just data**. Instead of throwing them into the void and hoping someone catches them, return them as values that TypeScript can track. ## When to Use - You need to replace exception-heavy code with `Either` or `TaskEither`. - The task involves validation, domain errors, or clearer error contracts in TypeScript. - You want pragmatic fp-ts error-handling guidance for real application code. --- ## 1. Stop Throwing Everywhere ### The Problem with Exceptions Exceptions are invisible in your types. They break the contract between functions. ```typescript // What this function signature promises: function getUser(id: string): User // What it actually does: function getUser(id: string): User { if (!id) throw new Error('ID required') const user = db.find(id) if (!user) throw new Error('User not found') return user } // The caller has no idea this can fail const user = getUser(id) // Might explode! ``` You end up with code like this: ```typescript // MESSY: try/catch everywhere function proces
- When to Use
- 1. Stop Throwing Everywhere
- The Problem with Exceptions
- The Solution: Return Errors as Values
- 2. The Result Pattern (Either)
- Converting Throwing Code to Either
- Common Either Operations
- 3. Chaining Operations That Might Fail
- Before: Nested Try/Catch Hell
- After: Clean Chain with Either
- Different Error Types? Use chainW
- 4. Collecting Multiple Errors
- Before: Collecting Errors Manually
- After: Validation with Error Accumulation
What does the fp-errors skill do?
Stop throwing everywhere - handle errors as values using Either and TaskEither for cleaner, more predictable code
How do I install it?
Run `npx skills add sickn33/agentic-awesome-skills --skill fp-errors --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From sickn33/agentic-awesome-skills, a repository with 44,414 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.