A simple CLI tool to help you handle exceptions globally in your NestJS application, promoting best practices and standardization.
You can install the CLI globally or use it directly with npx.
npm install -g @mrathod05/nestjs-exception-handler
or
npx nestjs-exception-handler
Run the CLI in your project root:
npx nestjs-exception-handler
The CLI will help you integrate global exception handling by creating the necessary files for a standard setup.
Note: This tool does not install @nestjs/common or express automatically. It will remind you to install them yourself using your preferred package manager.
Guides you through setting up a global exception handler in your NestJS app
Promotes best practices for structured and consistent error handling
Configures response formats, stack traces, and logging for better debugging
Ensures you follow the proper NestJS structure for exception handling
$ npx nestjs-exception-handler
⚙️ nestjs-exception-handler
Generate a customizable GlobalExceptionHandler for NestJS
✔ 👉 Enter target directory (e.g., src/common/filters) · test
✅ Global exception handler created at test/global-exception.filter.ts
📦 Required Dependencies:
Ensure the following packages are installed in your project:
- @nestjs/common → Core NestJS package for decorators and exception handling.
- express → Web server framework used by NestJS under the hood.
📥 Install via:
npm: npm install @nestjs/common express
yarn: yarn add @nestjs/common express
pnpm: pnpm add @nestjs/common express