error-handling-typescript

Define typed errors and Result-style returns for TypeScript async boundaries.

Updated Feb 24, 2026
One-click install
npx skills add https://github.com/brian861105/codex-skills --skill error-handling-typescript
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: error-handling-typescript
Source: https://github.com/brian861105/codex-skills/tree/main/error-handling-typescript
Command: npx skills add https://github.com/brian861105/codex-skills --skill error-handling-typescript

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Explicit, typed error handling in TypeScript reduces silent failures and simplifies debugging across async boundaries.

Core Features & Use Cases

  • Custom error classes with codes, status, and context
  • Result-style returns for recoverable failures
  • Targeted try/catch blocks with clear boundaries across modules

Quick Start

Implement a complete error-handling strategy for a TypeScript project using typed errors and Result-style returns.

Frequently Asked Questions about error-handling-typescript

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

FAQPage Schema
How do I handle async errors in TypeScript without silent failures?

To handle async errors in TypeScript without silent failures, define explicit typed errors and establish safe async boundaries. Apply custom error classes and Result-style returns across service layers and API adapters to capture expected and unexpected failures with clear context.

What is the best way to implement custom error classes in TypeScript?

The best way to implement custom error classes in TypeScript is to define them with specific codes, status information, and context. This approach allows targeted try/catch blocks to differentiate between expected recoverable failures and unexpected issues across modules.

Should I use Result-style returns or try/catch blocks for TypeScript exception handling?

Use Result-style returns for recoverable failures to enforce explicit error checking at compile time, while applying targeted try/catch blocks for unexpected failures. Combining both patterns across service layers and repositories prevents silent failures and simplifies debugging.

How do I structure error handling across service layers and API adapters in TypeScript?

Structure error handling across TypeScript service layers and API adapters by applying consistent typed error patterns. Implement custom error classes with context and codes, use Result-style returns for recoverable failures, and wrap boundaries in targeted try/catch blocks.

When do I need typed error handling patterns in TypeScript?

You need typed error handling patterns in TypeScript when reducing silent failures and simplifying debugging across async boundaries. Explicit typed errors are essential when managing complex modules like service layers, repositories, and API adapters where unexpected failures occur.

Why does TypeScript not catch my async exceptions in service layers?

TypeScript may not catch async exceptions in service layers due to untyped or unbounded async boundaries. Resolve this by implementing safe async boundaries, applying targeted try/catch blocks, and returning explicit Result-style objects to capture failure context and codes.