error-handling

Map NestJS exceptions to consistent ApiErrorResponse payloads across layers.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/mthang1801/go-domain-driven-design --skill error-handling-mthang1801
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: error-handling
Source: https://github.com/mthang1801/go-domain-driven-design/tree/main/.claude/skills/error-handling
Command: npx skills add https://github.com/mthang1801/go-domain-driven-design --skill error-handling-mthang1801

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Error handling across multiple layers in a NestJS app can become inconsistent, making failures hard to diagnose and users receive unclear responses.

Core Features & Use Cases

  • Structured error mapping from domain, use-case, and infrastructure exceptions to a consistent ApiErrorResponse.
  • Interceptor-driven logging and tracing (TransformInterceptor and TransformUseSentryInterceptor) with Telegram notifications for critical failures.
  • RPC adapters and fallback handlers ensure uniform error semantics across microservice boundaries and external calls.

Quick Start

Configure the TransformUseSentryInterceptor and ExceptionInterceptor in AppModule, then throw different exceptions (UsecaseException, InfrastructureException, DomainException) to verify standardized responses.

Frequently Asked Questions about error-handling

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

FAQPage Schema
How do I standardize API error responses across NestJS layers?

Map exceptions to a consistent ApiErrorResponse across NestJS controllers, use-case services, and infrastructure adapters to ensure uniform API error payloads. Structured error mapping eliminates inconsistent failure diagnostics.

How does NestJS handle domain, use-case, and infrastructure exceptions?

NestJS exception handling categorizes failures into UsecaseException, InfrastructureException, DomainException, ThirdPartyException, and I18nValidationException. Each exception type maps to a structured ApiErrorResponse for consistent client feedback.

How do I send Telegram alerts for critical NestJS failures?

Trigger Telegram alerts for critical NestJS failures by configuring interceptor-driven logging and tracing. The TransformUseSentryInterceptor and ExceptionInterceptor automatically dispatch notifications when critical exceptions occur.

Can I strip stack traces from API error payloads in production?

Stack traces are stripped in production to secure API error payloads. The error handling mechanism ensures sensitive debugging details remain internal while returning clean ApiErrorResponse objects to clients.

How do I configure interceptors for NestJS error handling?

Configure TransformUseSentryInterceptor and ExceptionInterceptor in AppModule to enable NestJS error handling. Throw UsecaseException, InfrastructureException, or DomainException to verify standardized API responses.

Does NestJS error handling work across microservice boundaries?

RPC adapters and fallback handlers ensure uniform error semantics across microservice boundaries and external calls. This maintains consistent API error payloads even when failures occur in remote service interactions.