-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
107 additions
and
12 deletions.
There are no files selected for viewing
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,8 @@ | ||
/** | ||
Map of error constructors to recreate from the serialize `name` property. If the name is not found in this map, the errors will be deserialized as simple `Error` instances. | ||
Warning: Only simple and standard error constructors are supported, like `new MyCustomError(name)`. If your error constructor *requires* a second parameter or does not accept a string as first parameter, adding it to this map *will* break the deserialization. | ||
*/ | ||
declare const errorConstructors: Map<string, ErrorConstructor>; | ||
|
||
export default errorConstructors; |
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,26 @@ | ||
const list = [ | ||
// Native ES errors https://262.ecma-international.org/12.0/#sec-well-known-intrinsic-objects | ||
EvalError, | ||
RangeError, | ||
ReferenceError, | ||
SyntaxError, | ||
TypeError, | ||
URIError, | ||
|
||
// Built-in errors | ||
globalThis.DOMException, | ||
|
||
// Node-specific errors | ||
// https://nodejs.org/api/errors.html | ||
globalThis.AssertionError, | ||
globalThis.SystemError, | ||
] | ||
// Non-native Errors are used with `globalThis` because they might be missing. This filter drops them when undefined. | ||
.filter(Boolean) | ||
.map( | ||
constructor => [constructor.name, constructor], | ||
); | ||
|
||
const errorConstructors = new Map(list); | ||
|
||
export default errorConstructors; |
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