|
|
@ -1,7 +1,8 @@ |
|
|
|
import { Catch, Logger, NotFoundException, Optional } from '@nestjs/common'; |
|
|
|
import { Catch, Logger, NotFoundException, Optional } from '@nestjs/common'; |
|
|
|
import { InjectSentry, SentryService } from '@ntegral/nestjs-sentry'; |
|
|
|
import { InjectSentry, SentryService } from '@ntegral/nestjs-sentry'; |
|
|
|
|
|
|
|
import { ThrottlerException } from '@nestjs/throttler'; |
|
|
|
import type { ArgumentsHost, ExceptionFilter } from '@nestjs/common'; |
|
|
|
import type { ArgumentsHost, ExceptionFilter } from '@nestjs/common'; |
|
|
|
import type { Response } from 'express'; |
|
|
|
import type { Request, Response } from 'express'; |
|
|
|
import { |
|
|
|
import { |
|
|
|
AjvError, |
|
|
|
AjvError, |
|
|
|
BadRequest, |
|
|
|
BadRequest, |
|
|
@ -25,6 +26,7 @@ export class GlobalExceptionFilter implements ExceptionFilter { |
|
|
|
catch(exception: any, host: ArgumentsHost) { |
|
|
|
catch(exception: any, host: ArgumentsHost) { |
|
|
|
const ctx = host.switchToHttp(); |
|
|
|
const ctx = host.switchToHttp(); |
|
|
|
const response = ctx.getResponse<Response>(); |
|
|
|
const response = ctx.getResponse<Response>(); |
|
|
|
|
|
|
|
const request = ctx.getRequest<Request>(); |
|
|
|
|
|
|
|
|
|
|
|
// skip unnecessary error logging
|
|
|
|
// skip unnecessary error logging
|
|
|
|
if ( |
|
|
|
if ( |
|
|
@ -37,11 +39,20 @@ export class GlobalExceptionFilter implements ExceptionFilter { |
|
|
|
exception instanceof NotFound || |
|
|
|
exception instanceof NotFound || |
|
|
|
exception instanceof NotImplemented || |
|
|
|
exception instanceof NotImplemented || |
|
|
|
exception instanceof UnprocessableEntity || |
|
|
|
exception instanceof UnprocessableEntity || |
|
|
|
exception instanceof NotFoundException |
|
|
|
exception instanceof NotFoundException || |
|
|
|
|
|
|
|
exception instanceof ThrottlerException |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
this.logger.error(exception.message, exception.stack); |
|
|
|
this.logger.error(exception.message, exception.stack); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (exception instanceof ThrottlerException) { |
|
|
|
|
|
|
|
this.logger.log( |
|
|
|
|
|
|
|
`${exception.message}, Path : ${request.path}, Workspace ID : ${ |
|
|
|
|
|
|
|
(request as any).ncWorkspaceId |
|
|
|
|
|
|
|
}, Project ID : ${(request as any).ncProjectId}`,
|
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// API not found
|
|
|
|
// API not found
|
|
|
|
if (exception instanceof NotFoundException) { |
|
|
|
if (exception instanceof NotFoundException) { |
|
|
|
this.logger.debug(exception.message, exception.stack); |
|
|
|
this.logger.debug(exception.message, exception.stack); |
|
|
|