انتقل إلى المحتوى الرئيسي

Class: ProblemDetailsFilter

Defined in: packages/common/src/nest/problem.filter.ts:16

Renders every thrown error as an RFC 9457 problem with the correlation id.

This is where error objects are serialised and so where a key most plausibly leaks (chapter 11): the response never contains the original message or stack. Those go to the log, which redacts. Install with app.useGlobalFilters(new ProblemDetailsFilter(app.get(HttpAdapterHost), logger)).

Implements​

  • ExceptionFilter

Constructors​

Constructor​

new ProblemDetailsFilter(adapterHost, logger?): ProblemDetailsFilter

Defined in: packages/common/src/nest/problem.filter.ts:24

Parameters​

adapterHost​

HttpAdapterHost

Nest's HttpAdapterHost, so the filter is adapter-neutral.

logger?​

Logger

Receives the original error for 5xx. Optional so tests can omit it.

Returns​

ProblemDetailsFilter

Methods​

catch()​

catch(exception, host): void

Defined in: packages/common/src/nest/problem.filter.ts:30

Nest's filter entry point.

Parameters​

exception​

unknown

host​

ArgumentsHost

Returns​

void

Implementation of​

ExceptionFilter.catch