error-handling

Design recoverability-based error handling using Either and Result types across seven languages.

Updated Jun 23, 2026
One-click install
npx skills add https://github.com/j5ik2o/marp-ai-base --skill error-handling-j5ik2o
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: error-handling
Source: https://github.com/j5ik2o/marp-ai-base/tree/main/.agents/skills/error-handling
Command: npx skills add https://github.com/j5ik2o/marp-ai-base --skill error-handling-j5ik2o

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Inconsistent error handling leads to unclear APIs, swallowed exceptions, and fragile code. This Skill provides a decision framework for classifying errors by recoverability and applying Either/Result types for recoverable errors while reserving exceptions for unrecoverable failures. ## Core Features & Use Cases - Recoverability-Based Classification: Distinguishes recoverable errors (business rule violations, external system failures) from unrecoverable ones (invalid arguments, inconsistent state, unreachable code). - Multi-Language Implementation Patterns: Provides concrete code examples for TypeScript (neverthrow, fp-ts), Rust (std Result + thiserror), Go (standard errors, samber/mo), Scala (Either), Java (vavr), and Python (returns, result). - Error Type Design: Covers union types, enums, and sealed classes/interfaces for modeling domain errors. - Use Case: When refactoring a service layer, use this Skill to convert thrown exceptions into typed Result returns so callers can see all failure modes directly in the function signature. ## Quick Start Ask the AI to review your function's error handling and redesign it using Result types based on whether each error is recoverable.

Frequently Asked Questions about error-handling

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use Result types instead of exceptions in TypeScript?▼

Use the neverthrow library to return Result<T, E> from functions, wrapping success values in ok() and failures in err(). Define error cases as a union type so callers can exhaustively handle each failure mode.

When should I use Result types versus throwing exceptions?▼

Use Result types for recoverable errors like validation failures, not-found resources, and external system errors where the caller decides how to respond. Throw exceptions only for unrecoverable conditions like null arguments, inconsistent state, or unreachable code.

neverthrow vs fp-ts for TypeScript error handling?▼

Choose neverthrow when you only need Result types, as it is lightweight and simple. Choose fp-ts when you also need broader functional programming utilities like Option, Task, IO, and Reader.

What error handling library should I use in Go?▼

Use the standard (T, error) return pattern for idiomatic Go code. If you want Result/Either chaining with Map and FlatMap operations, use the samber/mo library instead.

How do I define domain error types in Rust?▼

Define errors as an enum with the thiserror crate, deriving Error and using #[error] attributes for display messages. Return them with the standard Result<T, E> type from functions.

When should error handling use panic instead of Result?▼

Use panic or exceptions only for unrecoverable programmer errors: invalid arguments, contradictory object state, and logically unreachable branches. These indicate bugs that should stop execution immediately rather than be handled by callers.