Browse Source

refactor: sentry capturing

pull/6772/head
Pranav C 1 year ago
parent
commit
9faaf38f37
  1. 10
      packages/nocodb/src/filters/global-exception/global-exception.filter.ts

10
packages/nocodb/src/filters/global-exception/global-exception.filter.ts

@ -18,10 +18,10 @@ import {
@Catch() @Catch()
export class GlobalExceptionFilter implements ExceptionFilter { export class GlobalExceptionFilter implements ExceptionFilter {
constructor( 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) { catch(exception: any, host: ArgumentsHost) {
const ctx = host.switchToHttp(); const ctx = host.switchToHttp();
@ -106,7 +106,7 @@ export class GlobalExceptionFilter implements ExceptionFilter {
if (exception.getStatus?.()) { if (exception.getStatus?.()) {
response.status(exception.getStatus()).json(exception.getResponse()); response.status(exception.getStatus()).json(exception.getResponse());
} else { } else {
this.sentryClient?.instance().captureException(exception); this.captureException(exception, request);
// todo: change the response code // todo: change the response code
response.status(400).json({ response.status(400).json({
@ -114,4 +114,8 @@ export class GlobalExceptionFilter implements ExceptionFilter {
}); });
} }
} }
protected captureException(exception: any, _request: any) {
this.sentryClient?.instance().captureException(exception);
}
} }

Loading…
Cancel
Save