Created
October 15, 2020 12:33
-
-
Save wentout/41ff45bfa22e5a0330eb3ea8e64aec74 to your computer and use it in GitHub Desktop.
Error Manifestation Example
This file contains hidden or 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
| 'use strict'; | |
| const GenerateError = function (error) { | |
| if (!(error instanceof Error)) { | |
| error = new Error('defaults'); | |
| } | |
| debugger; | |
| Object.setPrototypeOf( | |
| Object.getPrototypeOf( | |
| Object.getPrototypeOf(this)), error); | |
| }; | |
| class ManifestateError extends GenerateError { | |
| constructor(error) { | |
| super(error); | |
| } | |
| }; | |
| const erroredInstance = new ManifestateError(new Error('my error')); | |
| console.log(erroredInstance instanceof Error) // true | |
| console.log(erroredInstance instanceof GenerateError) // true | |
| console.log(erroredInstance instanceof ManifestateError) // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment