Skip to content

Function: Catch()

ts
function Catch(...exceptions): ClassDecorator;

Defined in: packages/microservices/src/decorators/catch.decorator.ts:18

Marks an exception filter class and declares which exception types it handles. Omitting arguments causes the filter to catch all exceptions.

Parameters

ParameterTypeDescription
...exceptions(...args) => Error[]Exception constructors this filter should handle.

Returns

ClassDecorator

Example

typescript
@Catch(HttpException, ValidationException)
class MyFilter implements ExceptionFilter {
  catch(exception: Error, context: ExceptionContext) { ... }
}

Released under the MIT License.