@concepta/nestjs-exception
TypeScript icon, indicating that this package has built-in type declarations

4.0.0 • Public • Published

Rockets NestJS Exception

Provide exception handling/normalization and error code mapping.

For more details on the exception filters pattern, please refer to the official NestJS Exception Filters documentation.

Project

NPM Latest NPM Downloads GH Last Commit GH Contrib NestJS Dep

Installation

yarn add @concepta/nestjs-exception

Binding The Filer

You can bind the filter to classes, methods and globally.

Class Decorator

// ...
import { ExceptionsFilter } from '@concepta/nestjs-exception';

@UseFilters(new ExceptionsFilter())
export class PhotoController {
  // ...
}

Method Decorator

// ...
import { ExceptionsFilter } from '@concepta/nestjs-exception';

@Post()
@UseFilters(new ExceptionsFilter())
async create(@Body() createPhotoDto: CreatePhotoDto) {
  throw new ForbiddenException();
}

Global Filter

// ...
import { ExceptionsFilter } from '@concepta/nestjs-exception';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  app.useGlobalFilters(new ExceptionsFilter());
  await app.listen(3000);
}
bootstrap();

TODO

  • Define interface for exception filter response payload.

Readme

Keywords

none

Package Sidebar

Install

npm i @concepta/nestjs-exception

Weekly Downloads

53

Version

4.0.0

License

BSD-3-Clause

Unpacked Size

16.5 kB

Total Files

21

Last publish

Collaborators

  • mrmaz
  • leoafarias