Skip to content

Commit

Permalink
Improved error message in response handler
Browse files Browse the repository at this point in the history
  • Loading branch information
rgins16 committed Jul 14, 2023
1 parent af74365 commit 7f69f90
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/msal-common/src/response/ResponseHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ export class ResponseHandler {
serverResponse.error_description ||
serverResponse.suberror
) {
const errString = `${serverResponse.error_codes} - [${serverResponse.timestamp}]: ${serverResponse.error_description} - Correlation ID: ${serverResponse.correlation_id} - Trace ID: ${serverResponse.trace_id}`;
const serverError = new ServerError(
serverResponse.error,
errString,
serverResponse.suberror
);

// check if 500 error
if (
Expand All @@ -173,7 +179,7 @@ export class ResponseHandler {
(serverResponse.status <= HttpStatus.SERVER_ERROR_RANGE_END)
) {
this.logger.warning(
"executeTokenRequest:validateTokenResponse - AAD is currently unavailable and the access token is unable to be refreshed."
`executeTokenRequest:validateTokenResponse - AAD is currently unavailable and the access token is unable to be refreshed. ${serverError}`
);

// don't throw an exception, but alert the user via a log that the token was unable to be refreshed
Expand All @@ -186,7 +192,7 @@ export class ResponseHandler {
(serverResponse.status <= HttpStatus.CLIENT_ERROR_RANGE_END)
) {
this.logger.warning(
"executeTokenRequest:validateTokenResponse - AAD is currently available but is unable to refresh the access token."
`executeTokenRequest:validateTokenResponse - AAD is currently available but is unable to refresh the access token. ${serverError}`
);

// don't throw an exception, but alert the user via a log that the token was unable to be refreshed
Expand All @@ -211,12 +217,7 @@ export class ResponseHandler {
);
}

const errString = `${serverResponse.error_codes} - [${serverResponse.timestamp}]: ${serverResponse.error_description} - Correlation ID: ${serverResponse.correlation_id} - Trace ID: ${serverResponse.trace_id}`;
throw new ServerError(
serverResponse.error,
errString,
serverResponse.suberror
);
throw serverError;
}
}

Expand Down

0 comments on commit 7f69f90

Please sign in to comment.