Skip to content

ErrorFilter

Defined in: packages/nestjs/src/filters/error.filter.ts:21

Answers every error through NestJS’s own exception handling: an error of a @cqrs-ddd package is first converted to its NestJS HttpException (see httpAnswer), with its headers such as Retry-After; anything else is handled exactly as Nest handles it by default. It works on Express and Fastify, also for errors thrown in middleware.

@Module({ providers: [{ provide: APP_FILTER, useClass: ErrorFilter }] })
export class AppModule {}
  • BaseExceptionFilter

new ErrorFilter(applicationRef?): ErrorFilter

Defined in: node_modules/.pnpm/@nestjs+core@12.1.2_@nestjs+common@12.1.2_reflect-metadata@0.2.2_rxjs@7.8.2_supports-co_a974753d16f97f740228400be34cb4bf/node_modules/@nestjs/core/exceptions/base-exception-filter.d.ts:8

HttpServer<any, any, any>

ErrorFilter

BaseExceptionFilter.constructor

protected readonly optional applicationRef?: HttpServer<any, any, any>

Defined in: node_modules/.pnpm/@nestjs+core@12.1.2_@nestjs+common@12.1.2_reflect-metadata@0.2.2_rxjs@7.8.2_supports-co_a974753d16f97f740228400be34cb4bf/node_modules/@nestjs/core/exceptions/base-exception-filter.d.ts:5

BaseExceptionFilter.applicationRef


protected readonly optional httpAdapterHost?: HttpAdapterHost<AbstractHttpAdapter<any, any, any>>

Defined in: node_modules/.pnpm/@nestjs+core@12.1.2_@nestjs+common@12.1.2_reflect-metadata@0.2.2_rxjs@7.8.2_supports-co_a974753d16f97f740228400be34cb4bf/node_modules/@nestjs/core/exceptions/base-exception-filter.d.ts:7

BaseExceptionFilter.httpAdapterHost

catch(exception, host): void

Defined in: packages/nestjs/src/filters/error.filter.ts:22

unknown

ArgumentsHost

void

BaseExceptionFilter.catch


handleUnknownError(exception, host, applicationRef): void

Defined in: node_modules/.pnpm/@nestjs+core@12.1.2_@nestjs+common@12.1.2_reflect-metadata@0.2.2_rxjs@7.8.2_supports-co_a974753d16f97f740228400be34cb4bf/node_modules/@nestjs/core/exceptions/base-exception-filter.d.ts:10

any

ArgumentsHost

HttpServer<any, any, any> | AbstractHttpAdapter<any, any, any>

void

BaseExceptionFilter.handleUnknownError


isExceptionObject(err): err is Error

Defined in: node_modules/.pnpm/@nestjs+core@12.1.2_@nestjs+common@12.1.2_reflect-metadata@0.2.2_rxjs@7.8.2_supports-co_a974753d16f97f740228400be34cb4bf/node_modules/@nestjs/core/exceptions/base-exception-filter.d.ts:11

any

err is Error

BaseExceptionFilter.isExceptionObject


isHttpError(err): err is { message: string; statusCode: number }

Defined in: node_modules/.pnpm/@nestjs+core@12.1.2_@nestjs+common@12.1.2_reflect-metadata@0.2.2_rxjs@7.8.2_supports-co_a974753d16f97f740228400be34cb4bf/node_modules/@nestjs/core/exceptions/base-exception-filter.d.ts:16

Checks if the thrown error is a FastifyError or comes from the “http-errors” library.

any

error object

err is { message: string; statusCode: number }

BaseExceptionFilter.isHttpError