Use when Effect error handling patterns including catchAll, catchTag, either, option, and typed errors. Use for handling expected errors in Effect applications.
View on GitHubFebruary 5, 2026
Select agents to install to:
npx add-skill https://github.com/TheBushidoCollective/han/blob/main/plugins/frameworks/effect/skills/effect-error-handling/SKILL.md -a claude-code --skill effect-error-handlingInstallation paths:
.claude/skills/effect-error-handling/# Effect Error Handling
Master type-safe error handling in Effect applications. This skill covers
expected errors, error recovery, selective error handling, and error
transformations using Effect's error management operators.
## Expected Errors vs Defects
Effect distinguishes between two types of failures:
- **Expected Errors (E channel)**: Recoverable errors tracked in the type system
- **Defects**: Unexpected failures (bugs, programming errors)
```typescript
import { Effect } from "effect"
// Expected error - tracked in type
interface ValidationError {
_tag: "ValidationError"
field: string
message: string
}
const validateEmail = (email: string): Effect.Effect<string, ValidationError, never> => {
if (!email.includes("@")) {
return Effect.fail({
_tag: "ValidationError",
field: "email",
message: "Invalid email format"
})
}
return Effect.succeed(email)
}
// Defect - throws, becomes unexpected failure
const riskyOperation = Effect.sync(() => {
throw new Error("Unexpected error") // This is a defect
})
// Proper way - expected error
const safeOperation = Effect.try({
try: () => {
// Code that might throw
return riskyParse(data)
},
catch: (error) => ({
_tag: "ParseError",
message: String(error)
})
})
```
## Tagged Error Types
Use tagged unions for error types to enable pattern matching:
```typescript
import { Effect } from "effect"
// Define tagged error types
interface NotFoundError {
_tag: "NotFoundError"
id: string
}
interface UnauthorizedError {
_tag: "UnauthorizedError"
userId: string
}
interface NetworkError {
_tag: "NetworkError"
message: string
}
type AppError = NotFoundError | UnauthorizedError | NetworkError
// Functions returning typed errors
const fetchUser = (id: string): Effect.Effect<User, NotFoundError | NetworkError, never> => {
// Implementation
}
const authenticate = (token: string): Effect.Effect<User, UnauthorizedError | NetworkError, never> => {
// Impl