|
@@ -13,13 +13,19 @@ export class AllExceptionsFilter implements ExceptionFilter {
|
|
|
const ctx = host.switchToHttp()
|
|
const ctx = host.switchToHttp()
|
|
|
|
|
|
|
|
const httpStatus = exception instanceof HttpException ? exception.getStatus() : HttpStatus.INTERNAL_SERVER_ERROR
|
|
const httpStatus = exception instanceof HttpException ? exception.getStatus() : HttpStatus.INTERNAL_SERVER_ERROR
|
|
|
-
|
|
|
|
|
- const res = {
|
|
|
|
|
|
|
+ const path = httpAdapter.getRequestUrl(ctx.getRequest())
|
|
|
|
|
+ let res: any = {
|
|
|
status: httpStatus,
|
|
status: httpStatus,
|
|
|
path: httpAdapter.getRequestUrl(ctx.getRequest()),
|
|
path: httpAdapter.getRequestUrl(ctx.getRequest()),
|
|
|
message: (exception as any).message
|
|
message: (exception as any).message
|
|
|
}
|
|
}
|
|
|
- Logger.error(`status=${res.status}, path=${res.path}, msg=${res.message}`, 'GlobalExceptionFilter')
|
|
|
|
|
|
|
+ if (exception instanceof HttpException) {
|
|
|
|
|
+ res = exception.getResponse()
|
|
|
|
|
+ if (res.message instanceof Array) {
|
|
|
|
|
+ res.message = res.message.join()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ Logger.error(`status=${httpStatus}, path=${path}, msg=${res.message}`, 'GlobalExceptionFilter')
|
|
|
|
|
|
|
|
httpAdapter.reply(ctx.getResponse(), res, httpStatus)
|
|
httpAdapter.reply(ctx.getResponse(), res, httpStatus)
|
|
|
}
|
|
}
|