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.
Example
Section titled “Example”Extends
Section titled “Extends”BaseExceptionFilter
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ErrorFilter(
applicationRef?):ErrorFilter
Defined in: node_modules/.pnpm/@nestjs+core@12.2.0_@nestjs+common@12.2.0_reflect-metadata@0.2.2_rxjs@7.8.2_supports-co_63490c78f25598d4728a78ad577f97d9/node_modules/@nestjs/core/exceptions/base-exception-filter.d.ts:8
Parameters
Section titled “Parameters”applicationRef?
Section titled “applicationRef?”HttpServer<any, any, any>
Returns
Section titled “Returns”ErrorFilter
Inherited from
Section titled “Inherited from”BaseExceptionFilter.constructor
Properties
Section titled “Properties”applicationRef?
Section titled “applicationRef?”
protectedreadonlyoptionalapplicationRef?:HttpServer<any,any,any>
Defined in: node_modules/.pnpm/@nestjs+core@12.2.0_@nestjs+common@12.2.0_reflect-metadata@0.2.2_rxjs@7.8.2_supports-co_63490c78f25598d4728a78ad577f97d9/node_modules/@nestjs/core/exceptions/base-exception-filter.d.ts:5
Inherited from
Section titled “Inherited from”BaseExceptionFilter.applicationRef
httpAdapterHost?
Section titled “httpAdapterHost?”
protectedreadonlyoptionalhttpAdapterHost?:HttpAdapterHost<AbstractHttpAdapter<any,any,any>>
Defined in: node_modules/.pnpm/@nestjs+core@12.2.0_@nestjs+common@12.2.0_reflect-metadata@0.2.2_rxjs@7.8.2_supports-co_63490c78f25598d4728a78ad577f97d9/node_modules/@nestjs/core/exceptions/base-exception-filter.d.ts:7
Inherited from
Section titled “Inherited from”BaseExceptionFilter.httpAdapterHost
Methods
Section titled “Methods”catch()
Section titled “catch()”catch(
exception,host):void
Defined in: packages/nestjs/src/filters/error.filter.ts:22
Parameters
Section titled “Parameters”exception
Section titled “exception”unknown
ArgumentsHost
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”BaseExceptionFilter.catch
handleUnknownError()
Section titled “handleUnknownError()”handleUnknownError(
exception,host,applicationRef):void
Defined in: node_modules/.pnpm/@nestjs+core@12.2.0_@nestjs+common@12.2.0_reflect-metadata@0.2.2_rxjs@7.8.2_supports-co_63490c78f25598d4728a78ad577f97d9/node_modules/@nestjs/core/exceptions/base-exception-filter.d.ts:10
Parameters
Section titled “Parameters”exception
Section titled “exception”any
ArgumentsHost
applicationRef
Section titled “applicationRef”HttpServer<any, any, any> | AbstractHttpAdapter<any, any, any>
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”BaseExceptionFilter.handleUnknownError
isExceptionObject()
Section titled “isExceptionObject()”isExceptionObject(
err):err is Error
Defined in: node_modules/.pnpm/@nestjs+core@12.2.0_@nestjs+common@12.2.0_reflect-metadata@0.2.2_rxjs@7.8.2_supports-co_63490c78f25598d4728a78ad577f97d9/node_modules/@nestjs/core/exceptions/base-exception-filter.d.ts:11
Parameters
Section titled “Parameters”any
Returns
Section titled “Returns”err is Error
Inherited from
Section titled “Inherited from”BaseExceptionFilter.isExceptionObject
isHttpError()
Section titled “isHttpError()”isHttpError(
err):err is { expose?: boolean; message: string; statusCode: number }
Defined in: node_modules/.pnpm/@nestjs+core@12.2.0_@nestjs+common@12.2.0_reflect-metadata@0.2.2_rxjs@7.8.2_supports-co_63490c78f25598d4728a78ad577f97d9/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.
Parameters
Section titled “Parameters”any
error object
Returns
Section titled “Returns”err is { expose?: boolean; message: string; statusCode: number }
Inherited from
Section titled “Inherited from”BaseExceptionFilter.isHttpError