error-handler

Implement centralized typed AppError hierarchy and global middleware for TypeScript API services.

11|Updated Apr 16, 2026
One-click install
npx skills add https://github.com/berkcangumusisik/claude-code-practices --skill error-handler-berkcangumusisik
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: error-handler
Source: https://github.com/berkcangumusisik/claude-code-practices/tree/main/skills/error-handler
Command: npx skills add https://github.com/berkcangumusisik/claude-code-practices --skill error-handler-berkcangumusisik

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

API projects often suffer from inconsistent error handling, leading to unclear responses and brittle code. This Skill provides a centralized, typed error system with a shared AppError hierarchy, clear status codes, and a global error handler to standardize failures.

Core Features & Use Cases

  • Typed error classes: AppError and derived classes (NotFoundError, ValidationError, UnauthorizedError) with dedicated HTTP status codes.
  • Global error handling middleware: A single place to format and return uniform error responses to clients.
  • Optional Result type: A pattern to represent failures without throwing, enabling safer failure paths and easier testing.
  • Migration guidance: Steps to replace generic try/catch blocks across existing codebases.

Quick Start

Define AppError and derived classes, add a global error handler, and migrate error handling to use typed errors and the Result pattern.

Frequently Asked Questions about error-handler

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

FAQPage Schema
How do I implement centralized error handling in a TypeScript API?▼

Centralized error handling in a TypeScript API is implemented by creating a shared AppError hierarchy with typed error classes and routing them through a single global error handler middleware to format uniform responses.

What is a typed Result pattern in API error handling?▼

A typed Result pattern in API error handling is a mechanism that represents failures as return values instead of throwing exceptions, enabling safer failure paths and easier testing in server-side JavaScript codebases.

How do I standardize HTTP error responses for NotFound and Validation errors?▼

You can standardize HTTP error responses by defining typed error classes like NotFoundError and ValidationError that carry dedicated HTTP status codes, then passing them to a global error handling middleware.

How do I migrate existing try/catch blocks to a centralized error hierarchy?▼

Migrating existing try/catch blocks involves replacing generic exception catching with typed AppError instances and utilizing the optional Result pattern to handle failure paths without throwing.

Can I use this typed error system for unauthorized errors in JavaScript routes?▼

Yes, this typed error system supports unauthorized errors in JavaScript routes by using a dedicated UnauthorizedError class that integrates directly with the global middleware to return consistent HTTP status codes.