Skip to content

Commit 56bb5fc

Browse files
fix(core): add logging to external exception filter
1 parent b1f647f commit 56bb5fc

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
import { ArgumentsHost } from '@nestjs/common';
1+
import { ArgumentsHost, HttpException, Logger } from '@nestjs/common';
22

33
export class ExternalExceptionFilter<T = any, R = any> {
4+
private static readonly logger = new Logger('ExceptionsHandler');
5+
46
catch(exception: T, host: ArgumentsHost): R | Promise<R> {
7+
if (exception instanceof Error && !(exception instanceof HttpException)) {
8+
ExternalExceptionFilter.logger.error(exception.message, exception.stack);
9+
}
510
return (exception as any) as R;
611
}
712
}

0 commit comments

Comments
 (0)