From 96fba580be3fcf50eb2d4770bf56d6f63f6a57b0 Mon Sep 17 00:00:00 2001 From: Abhishek Y Date: Wed, 17 Jul 2024 11:59:01 +0530 Subject: [PATCH] Handling error message to be sent when BPP response fails validation tests --- src/middlewares/schemaValidator.middleware.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/middlewares/schemaValidator.middleware.ts b/src/middlewares/schemaValidator.middleware.ts index c6b8657..8533acf 100644 --- a/src/middlewares/schemaValidator.middleware.ts +++ b/src/middlewares/schemaValidator.middleware.ts @@ -203,14 +203,17 @@ export const schemaErrorHandler = ( if (err instanceof Exception) { next(err); } else { - const errorData = new Exception( - ExceptionType.OpenApiSchema_ParsingError, - `OpenApiValidator Error at ${protocolServerLevel}`, - err.status, - err - ); - - next(errorData); + console.log('OpenApiValidator Error', err); + req.body = { + ...req.body, + message: {}, + error: { + code: err.status + '', + path: err.path, + message: err.message + } + } + next(); } };