Created
September 29, 2016 15:05
-
-
Save tralamazza/83b5246b3c27beb23223d7c2cf2c561b to your computer and use it in GitHub Desktop.
node 6 custom error
This file contains 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
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