Skip to content

Instantly share code, notes, and snippets.

@brigand

brigand/error.js Secret

Last active January 11, 2019 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brigand/f9912df68a474a84f521d740cbaf0811 to your computer and use it in GitHub Desktop.
Save brigand/f9912df68a474a84f521d740cbaf0811 to your computer and use it in GitHub Desktop.
class MyError extends Error {
constructor(msg, cause) {
super(msg);
this.cause = cause;
}
toJSON() {
return {
type: 'MyError',
message: this.message,
cause: this.cause,
};
}
}
throw new MyError('higher level message', fileReadError);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment