Skip to content

Instantly share code, notes, and snippets.

@wentout
Created October 15, 2020 12:33
Show Gist options
  • Select an option

  • Save wentout/41ff45bfa22e5a0330eb3ea8e64aec74 to your computer and use it in GitHub Desktop.

Select an option

Save wentout/41ff45bfa22e5a0330eb3ea8e64aec74 to your computer and use it in GitHub Desktop.
Error Manifestation Example
'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