Skip to content

Commit

Permalink
Use Error.captureStackTrace to create the stack property
Browse files Browse the repository at this point in the history
  • Loading branch information
lpinca committed Aug 19, 2016
1 parent 3136901 commit 7f19f17
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
// - **error_description** (`String`) - the error description
//
var FigoError = function(error, error_description, errno) {
Error.captureStackTrace(this, FigoError);

this.name = 'FigoError';
this.error = error;
this.error_description = error_description;
this.message = this.error_description = error_description;
this.errno = errno;
this.stack = (new Error()).stack;
};
FigoError.prototype = Object.create(Error.prototype);
FigoError.prototype.constructor = FigoError;
Expand All @@ -20,5 +21,5 @@ FigoError.prototype.toString = function() {
};

module.exports = {
FigoError: FigoError
FigoError: FigoError
};

0 comments on commit 7f19f17

Please sign in to comment.