diff --git a/lib/msal-common/src/response/ResponseHandler.ts b/lib/msal-common/src/response/ResponseHandler.ts index c54987e324..d44b29a513 100644 --- a/lib/msal-common/src/response/ResponseHandler.ts +++ b/lib/msal-common/src/response/ResponseHandler.ts @@ -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 ( @@ -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 @@ -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 @@ -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; } }