Created
July 24, 2015 21:22
-
-
Save brianr/8be4b99513d3180b1813 to your computer and use it in GitHub Desktop.
NamedError - easily set the error 'name' property without defining a new class
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
function NamedError(name, message, extra) { | |
Error.captureStackTrace(this, this.constructor); | |
this.name = name; | |
this.message = message; | |
this.extra = extra; | |
}; | |
require('util').inherits(NamedError, Error); | |
module.exports = NamedError; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment