From 9faaf38f37d3ede6d9530a6461a403372b09c0d8 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Mon, 23 Oct 2023 05:42:27 +0000 Subject: [PATCH] refactor: sentry capturing --- .../global-exception/global-exception.filter.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/nocodb/src/filters/global-exception/global-exception.filter.ts b/packages/nocodb/src/filters/global-exception/global-exception.filter.ts index 1d2d2f940f..9c40d418ef 100644 --- a/packages/nocodb/src/filters/global-exception/global-exception.filter.ts +++ b/packages/nocodb/src/filters/global-exception/global-exception.filter.ts @@ -18,10 +18,10 @@ import { @Catch() export class GlobalExceptionFilter implements ExceptionFilter { constructor( - @Optional() @InjectSentry() private readonly sentryClient: SentryService, + @Optional() @InjectSentry() protected readonly sentryClient: SentryService, ) {} - private logger = new Logger(GlobalExceptionFilter.name); + protected logger = new Logger(GlobalExceptionFilter.name); catch(exception: any, host: ArgumentsHost) { const ctx = host.switchToHttp(); @@ -106,7 +106,7 @@ export class GlobalExceptionFilter implements ExceptionFilter { if (exception.getStatus?.()) { response.status(exception.getStatus()).json(exception.getResponse()); } else { - this.sentryClient?.instance().captureException(exception); + this.captureException(exception, request); // todo: change the response code response.status(400).json({ @@ -114,4 +114,8 @@ export class GlobalExceptionFilter implements ExceptionFilter { }); } } + + protected captureException(exception: any, _request: any) { + this.sentryClient?.instance().captureException(exception); + } }