Created
February 26, 2014 18:54
-
-
Save subfuzion/9235975 to your computer and use it in GitHub Desktop.
Revisions
-
subfuzion created this gist
Feb 26, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ Sometimes you want to wrap error objects with application-specific errors for your stack traces. Your custom error constructor: ``` function CustomError(e, extra) { Error.call(this); Error.captureStackTrace(this, CustomError); this.id = e.id; this.name = 'CustomError'; this.message = e.message } require('util').inherits(CustomError, Error); ``` Example usage: function doWork(callback) { doErrorProneWork(funtion(err, result) { if (err) return callback(new CustomError(err)); ... } }