Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#175440869] Improve Error mapping on UpdateUser log #97

Merged
merged 1 commit into from
Oct 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions UpdateUser/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)}`)
)
)
);

Expand All @@ -89,7 +93,7 @@ export function UpdateUserHandler(
const internalErrorHandler = (errorMessage: string, error: Error) =>
genericInternalErrorHandler(
context,
"UpdateUser | " + errorMessage,
"UpdateUser| " + errorMessage,
error,
errorMessage
);
Expand All @@ -111,7 +115,7 @@ export function UpdateUserHandler(
.mapLeft(error =>
internalErrorHandler(
"Could not update the user on the ADB2C",
error
new Error(JSON.stringify(error))
)
)
)
Expand Down