add-error-type

Create custom error classes extending BaseError with HTTP status mapping.

1|Updated May 21, 2025
One-click install
npx skills add https://github.com/madooei/backend-template --skill add-error-type
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-error-type
Source: https://github.com/madooei/backend-template/tree/main/.claude/skills/add-error-type
Command: npx skills add https://github.com/madooei/backend-template --skill add-error-type

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill enables teams to extend the domain error surface by introducing custom errors that integrate with the existing BaseError hierarchy and automatic HTTP status mapping, reducing boilerplate and improving consistency.

Core Features & Use Cases

  • Create a new error class that extends BaseError and defaults to a meaningful HTTP status via errorCode
  • Reuse and standardize common error types (e.g., BadRequestError, NotFoundError) across services
  • Apply business-rule validation across controllers and services with clear, actionable error messages

Quick Start

Create a new error class extending BaseError, implement it in your service layer, and throw it when a business rule is violated.

Frequently Asked Questions about add-error-type

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

FAQPage Schema
How do I define custom domain errors in TypeScript that map to HTTP status codes?

Yes, you can standardize error handling across backend controllers, services, and repositories by extending a BaseError class. This approach provides clear, actionable error messages and maps errorCodes to HTTP statuses for consistent business-rule validation.

What is the best way to reduce boilerplate when creating structured error types in a backend service?

You can implement domain-specific errors by creating a class that extends BaseError and throwing it when a business rule is violated. This integrates your custom error types directly into the service layer for structured error handling.

Does this approach to TypeScript error handling require existing dependencies?

This approach applies to backend services that need structured error handling. It relies on extending an existing BaseError hierarchy to integrate new domain-specific errors, but requires no additional external dependencies.

Why should I extend a BaseError hierarchy for backend error handling instead of using generic errors?

Extending a BaseError hierarchy enables automatic HTTP status mapping and reusable error types across your domain. This improves consistency and provides clear, actionable error messages compared to throwing generic errors.

Can I apply business-rule validation across controllers and services using custom error classes?

Yes, you can apply business-rule validation across controllers and services by throwing custom error classes that extend BaseError. This ensures structured error handling with clear, actionable messages when rules are violated.