@mrathod05/nestjs-exception-handler
v2.0.2
Published
A CLI tool to integrate a global exception handler into your NestJS project for better error handling and formatting.
Maintainers
Readme
⚡ NestJS Exception Handler CLI
A simple CLI tool to help you handle exceptions globally in your NestJS application, promoting best practices and standardization.
📦 Installation
You can install the CLI globally or use it directly with npx.
npm install -g @mrathod05/nestjs-exception-handleror
npx nestjs-exception-handler🚀 Usage
Run the CLI in your project root:
npx nestjs-exception-handlerThe 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.
🛠️ What It Does
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
🧪 Example
$ 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
🧑💻 Developer
Meet Rathod
