-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Capture and instrument cache errors (#7021)
- Add CacheError. - Capture and throw cache errors as CacheError. - Instrument the number of tokens in the cache if CacheError occurs.
- Loading branch information
1 parent
17a0bcb
commit b7c2309
Showing
14 changed files
with
489 additions
and
30 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@azure-msal-browser-f1688cf2-852c-4b32-a5b1-8b3a4393ace9.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "minor", | ||
"comment": "Capture and instrument cache errors #7021", | ||
"packageName": "@azure/msal-browser", | ||
"email": "kshabelko@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/@azure-msal-common-704006a4-ebc8-4197-85c9-261e01c15332.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "minor", | ||
"comment": "Capture and instrument cache errors #7021", | ||
"packageName": "@azure/msal-common", | ||
"email": "kshabelko@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
|
||
import * as CacheErrorCodes from "./CacheErrorCodes"; | ||
export { CacheErrorCodes }; | ||
|
||
export const CacheErrorMessages = { | ||
[CacheErrorCodes.cacheQuotaExceededErrorCode]: | ||
"Exceeded cache storage capacity.", | ||
[CacheErrorCodes.cacheUnknownErrorCode]: | ||
"Unexpected error occurred when using cache storage.", | ||
}; | ||
|
||
/** | ||
* Error thrown when there is an error with the cache | ||
*/ | ||
export class CacheError extends Error { | ||
/** | ||
* Short string denoting error | ||
*/ | ||
errorCode: string; | ||
|
||
/** | ||
* Detailed description of error | ||
*/ | ||
errorMessage: string; | ||
|
||
constructor(errorCode: string, errorMessage?: string) { | ||
const message = | ||
errorMessage || | ||
(CacheErrorMessages[errorCode] | ||
? CacheErrorMessages[errorCode] | ||
: CacheErrorMessages[CacheErrorCodes.cacheUnknownErrorCode]); | ||
|
||
super(`${errorCode}: ${message}`); | ||
Object.setPrototypeOf(this, CacheError.prototype); | ||
|
||
this.name = "CacheError"; | ||
this.errorCode = errorCode; | ||
this.errorMessage = message; | ||
} | ||
} |
Oops, something went wrong.