From 01040f7795c7f4d0403c196a3f5d7985b0d0a2e9 Mon Sep 17 00:00:00 2001 From: alexeh Date: Mon, 14 Oct 2024 07:11:32 +0200 Subject: [PATCH] add conditional logging for zod errors --- api/src/filters/all-exceptions.exception.filter.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/api/src/filters/all-exceptions.exception.filter.ts b/api/src/filters/all-exceptions.exception.filter.ts index 71574609..c9cb1684 100644 --- a/api/src/filters/all-exceptions.exception.filter.ts +++ b/api/src/filters/all-exceptions.exception.filter.ts @@ -31,7 +31,9 @@ export class AllExceptionsFilter implements ExceptionFilter { const errorDataForResponse: JSONAPIError = new JSONAPISerializer.Error( this.handleZodValidationErrorMessages(exception), ); - this.logger.error(errorDataForResponse); + if (this.apiConfig.get('NODE_ENV') !== 'test') { + this.logger.error(errorDataForResponse); + } return response.status(exception.getStatus()).json(errorDataForResponse); } else if (exception instanceof HttpException) { status = exception.getStatus(); @@ -64,13 +66,9 @@ export class AllExceptionsFilter implements ExceptionFilter { }); } if (this.apiConfig.get('NODE_ENV') !== 'test') { - this.logger.error('ENVIRONMENT IN CI'); - this.logger.error(this.apiConfig.get('NODE_ENV')); if (status >= 500) { - this.logger.error('TRIGGERING ERROR'); this.logger.error(errors); } else { - this.logger.error('TRIGGERING WARN'); this.logger.warn(errors); } }