error-handling

Implement consistent error handling for Node.js Express and NestJS backends.

3|Updated Apr 12, 2026
One-click install
npx skills add https://github.com/mauriciodelrio/delriodev-skills --skill error-handling-mauriciodelrio
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: error-handling
Source: https://github.com/mauriciodelrio/delriodev-skills/tree/main/es-skills/software/backend/error-handling
Command: npx skills add https://github.com/mauriciodelrio/delriodev-skills --skill error-handling-mauriciodelrio

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Inconsistent and unsafe error handling in backend services can expose internal details, cause crashes, and hinder debugging. This skill provides a unified approach for Node.js applications to manage operational and programming errors reliably.

Core Features & Use Cases

  • Define a base AppError class with status codes, error codes, and optional details.
  • Implement a global Express error‑handling middleware that formats responses and logs operational errors.
  • Create a NestJS global exception filter that mirrors the Express behavior for Nest applications.
  • Capture unhandled promise rejections and uncaught exceptions, then perform a graceful shutdown of the server, database, cache, and background workers.
  • Wrap external service calls in a helper that converts failures into consistent AppError instances.
  • Provide a checklist of common gotchas to avoid exposing stack traces or mixing error types.

Quick Start

Ask the assistant to generate a TypeScript error handling module for your Express or NestJS backend following the guidelines in this skill.

Frequently Asked Questions about error-handling

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

FAQPage Schema
How do I implement structured error handling in Node.js with TypeScript?

Structured error handling in Node.js with TypeScript is implemented using a base AppError class with status codes and a global middleware to format responses and log operational errors consistently.

How do I set up global error handling in Express and NestJS?

Global error handling in Express and NestJS is set up by adding an Express error-handling middleware or a NestJS global exception filter to catch, format, and log errors uniformly.

What is the best way to handle unhandled promise rejections in Node.js?

Unhandled promise rejections in Node.js are handled by capturing the events and triggering a graceful shutdown of the server, database, cache, and background workers to prevent data corruption.

How do I wrap external service call failures into consistent errors?

External service call failures are wrapped into consistent errors by using a helper function that catches failures and converts them into standardized AppError instances with appropriate status codes.

Does this error handling approach require a specific logging library?

This error handling approach requires TypeScript and a logger to record operational errors, but it does not mandate a specific logging library, allowing integration with your existing logging setup.

What are common gotchas when implementing custom error classes in Node.js?

Common gotchas when implementing custom error classes in Node.js include accidentally exposing stack traces to clients and improperly mixing operational errors with programming errors.