Skip to content

Instantly share code, notes, and snippets.

@brianr
Created July 24, 2015 21:22
Show Gist options
  • Save brianr/8be4b99513d3180b1813 to your computer and use it in GitHub Desktop.
Save brianr/8be4b99513d3180b1813 to your computer and use it in GitHub Desktop.
NamedError - easily set the error 'name' property without defining a new class
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