Skip to content

Instantly share code, notes, and snippets.

@tralamazza
Created September 29, 2016 15:05
Show Gist options
  • Save tralamazza/83b5246b3c27beb23223d7c2cf2c561b to your computer and use it in GitHub Desktop.
Save tralamazza/83b5246b3c27beb23223d7c2cf2c561b to your computer and use it in GitHub Desktop.
node 6 custom error
class CustomError extends Error {
constructor(message) {
super(message); // also sets .message
this.name = this.constructor.name; // and not 'Error'
Error.captureStackTrace(this, this.constructor); // remove ctor from the stacktrace
}
}
module.exports = CustomError;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment