Nestjs error handling

From HoangNguyen0403/agent-skills-standard · View interactive version

Nestjs error handling is an AI agent skill from the GitHub repository HoangNguyen0403/agent-skills-standard. Implement Global Exception Filters and standard error formats in NestJS. Use when implementing global exception filters or standardizing error responses in NestJS.

How to use this skill

Skill file

NestJS Error Handling Standards

**Priority: P1 (HIGH)**

```json

{

"statusCode": 400,

"message": "Validation failed",

"error": "Bad Request",

"timestamp": "ISO...",

"path": "/users"

}

```

Error Flow

  1. Service: Throws specific or generic errors (e.g., EntityNotFoundError).
  2. Interceptor: Maps low-level errors to HTTP Exceptions (e.g., catchError(err => throw new NotFoundException())).
  1. Global Filter: Formats final JSON response.

Built-in Exceptions

Logging

Security (Information Leakage)

Anti-Patterns

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.