botbook/node_modules/@azure/msal-common/dist/error/AuthError.mjs
Rodrigo Rodriguez 6ae15fe3e5 Updated.
2024-09-04 13:13:15 -03:00

56 lines
2 KiB
JavaScript

/*! @azure/msal-common v14.14.2 2024-08-28 */
'use strict';
import { Constants } from '../utils/Constants.mjs';
import { unexpectedError, postRequestFailed } from './AuthErrorCodes.mjs';
import * as AuthErrorCodes from './AuthErrorCodes.mjs';
export { AuthErrorCodes };
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
const AuthErrorMessages = {
[unexpectedError]: "Unexpected error in authentication.",
[postRequestFailed]: "Post request failed from the network, could be a 4xx/5xx or a network unavailability. Please check the exact error code for details.",
};
/**
* AuthErrorMessage class containing string constants used by error codes and messages.
* @deprecated Use AuthErrorCodes instead
*/
const AuthErrorMessage = {
unexpectedError: {
code: unexpectedError,
desc: AuthErrorMessages[unexpectedError],
},
postRequestFailed: {
code: postRequestFailed,
desc: AuthErrorMessages[postRequestFailed],
},
};
/**
* General error class thrown by the MSAL.js library.
*/
class AuthError extends Error {
constructor(errorCode, errorMessage, suberror) {
const errorString = errorMessage
? `${errorCode}: ${errorMessage}`
: errorCode;
super(errorString);
Object.setPrototypeOf(this, AuthError.prototype);
this.errorCode = errorCode || Constants.EMPTY_STRING;
this.errorMessage = errorMessage || Constants.EMPTY_STRING;
this.subError = suberror || Constants.EMPTY_STRING;
this.name = "AuthError";
}
setCorrelationId(correlationId) {
this.correlationId = correlationId;
}
}
function createAuthError(code, additionalMessage) {
return new AuthError(code, additionalMessage
? `${AuthErrorMessages[code]} ${additionalMessage}`
: AuthErrorMessages[code]);
}
export { AuthError, AuthErrorMessage, AuthErrorMessages, createAuthError };
//# sourceMappingURL=AuthError.mjs.map