From d59f845b828d73081774910173514c462693e527 Mon Sep 17 00:00:00 2001 From: AleDore Date: Mon, 26 Oct 2020 16:25:09 +0100 Subject: [PATCH] [#175440869] Improve Error mapping on log --- UpdateUser/handler.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/UpdateUser/handler.ts b/UpdateUser/handler.ts index 0140785e..0d83b59f 100644 --- a/UpdateUser/handler.ts +++ b/UpdateUser/handler.ts @@ -14,6 +14,7 @@ import { ContextMiddleware } from "io-functions-commons/dist/src/utils/middlewar import { RequiredBodyPayloadMiddleware } from "io-functions-commons/dist/src/utils/middlewares/required_body_payload"; import { RequiredParamMiddleware } from "io-functions-commons/dist/src/utils/middlewares/required_param"; import { withRequestMiddlewares } from "io-functions-commons/dist/src/utils/request_middleware"; +import { readableReport } from "italia-ts-commons/lib/reporters"; import { wrapRequestHandler } from "italia-ts-commons/lib/request_middleware"; import { IResponseErrorInternal, @@ -77,7 +78,10 @@ const updateUser = ( id: updateUserResponse.objectId, last_name: userPayload.last_name, token_name: userPayload.token_name - }).mapLeft(toError) + }).mapLeft( + errs => + new Error(`Error decoding UserUpdated ERROR=${readableReport(errs)}`) + ) ) ); @@ -89,7 +93,7 @@ export function UpdateUserHandler( const internalErrorHandler = (errorMessage: string, error: Error) => genericInternalErrorHandler( context, - "UpdateUser | " + errorMessage, + "UpdateUser| " + errorMessage, error, errorMessage ); @@ -111,7 +115,7 @@ export function UpdateUserHandler( .mapLeft(error => internalErrorHandler( "Could not update the user on the ADB2C", - error + new Error(JSON.stringify(error)) ) ) )