`export class DuplicateKeyExceptionFilter implements ExceptionFilter {
catch(exception: any, host: ArgumentsHost) {
// Check if it's a duplicate key error
const ctx = host.switchToHttp();
const response = ctx.getResponse();
const request: Request = ctx.getRequest();
if (exception.code === 11000) {
const value = exception.message.match(/(["'])(\\?.)*?\1/)[0];
const message = `Duplicate field value: ${value}. Please use another value!`;
response.status(HttpStatus.BAD_REQUEST).json({
statusCode: HttpStatus.BAD_REQUEST,
message,
timestamp: new Date().toISOString(),
path: request.url,
});
}
}`
I have this custom exception handler implemented globally. But it does not handle other exceptions, is it possible to pass those exceptions to the respective default handlers?