error-handling-patterns

Standardize Node.js/TypeScript error handling with AppError hierarchy and HTTP mappings.

11|2|Updated Apr 7, 2026
One-click install
npx skills add https://github.com/porcupine-md/jonggrang --skill error-handling-patterns-porcupine-md
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: error-handling-patterns
Source: https://github.com/porcupine-md/jonggrang/tree/main/skills/library/backend/error-handling-patterns
Command: npx skills add https://github.com/porcupine-md/jonggrang --skill error-handling-patterns-porcupine-md

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Production-ready error handling for Node.js/TypeScript backends by standardizing error construction, HTTP mapping, logging, and retry strategies.

Core Features & Use Cases

  • Unified AppError hierarchy across services to represent domain errors.
  • HTTP status mapping, consistent API error responses, and safe error exposure.
  • Async route handling wrapper to avoid unhandled rejections.
  • Retry and resilience patterns for flaky calls and external dependencies.
  • No-throw Result type for safer error propagation in calls.

Quick Start

Begin by replacing ad-hoc errors with the AppError hierarchy, wiring the error handling middleware, and applying the retry utilities in your API calls.

Frequently Asked Questions about error-handling-patterns

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

FAQPage Schema
How do I standardize error handling in a Node.js TypeScript backend?

Standardize error handling in a Node.js TypeScript backend by implementing a unified AppError hierarchy, mapping domain errors to HTTP statuses, and wiring middleware for consistent API responses. This replaces ad-hoc errors across services.

What is a no-throw Result type for safer error propagation?

A no-throw Result type for safer error propagation is a pattern that returns success or error values instead of throwing exceptions. This prevents unhandled rejections and makes call outcomes explicit in TypeScript backend code.

How do I avoid unhandled promise rejections in Express async routes?

Avoid unhandled promise rejections in Express async routes by wrapping route handlers with an async handler wrapper. This catches rejected promises and forwards them to centralized error handling middleware for safe logging and mapping.

What's the best way to implement retry patterns for flaky external API calls?

The best way to implement retry patterns for flaky external API calls is to apply dedicated retry utilities that re-attempt failed requests. This builds resilience into microservice backends dealing with unreliable external dependencies.

Can I use this error handling middleware for microservice backends?

Yes, you can use this error handling middleware for microservice backends. The approach applies to API services and microservices requiring robust error handling, consistent API responses, and safe error exposure across distributed systems.

How do I map domain errors to HTTP status codes in TypeScript?

Map domain errors to HTTP status codes in TypeScript by defining an AppError hierarchy with built-in status mappings. Centralized middleware intercepts these errors to produce consistent API responses and ensure safe error exposure to clients.