Created
September 24, 2016 14:48
-
-
Save watson/b46945a11c089fe74afa1e80739be4ac to your computer and use it in GitHub Desktop.
Creating custom error types in Node.js
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
var util = require('util') | |
util.inherits(NotFoundError, Error) | |
throw new NotFoundError('foo') | |
function NotFoundError (message) { | |
Error.captureStackTrace(this, this.constructor) | |
this.name = this.constructor.name | |
this.message = message | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment