Skip to content

Instantly share code, notes, and snippets.

@Kirill89
Last active March 24, 2020 22:33
Show Gist options
  • Save Kirill89/77d8fc925ac32d999affc29d759480d6 to your computer and use it in GitHub Desktop.
Save Kirill89/77d8fc925ac32d999affc29d759480d6 to your computer and use it in GitHub Desktop.
Custom error in JS
class GoodError extends Error {
constructor(...args) {
super(...args);
this.name = 'GoodError';
Error.captureStackTrace(this, GoodError);
}
}
export class GoodError extends Error {
public name = 'GoodError';
constructor(...args) {
super(...args);
Error.captureStackTrace(this, GoodError);
}
}
@Kirill89
Copy link
Author

JSON.stringify(err, Object.getOwnPropertyNames(err))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment