From 7f19f1706ac6661e83006ee7c7b5531b0e6dbc7d Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Fri, 19 Aug 2016 15:59:36 +0200 Subject: [PATCH] Use Error.captureStackTrace to create the stack property --- lib/errors.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/errors.js b/lib/errors.js index 86f5e33..c26e547 100644 --- a/lib/errors.js +++ b/lib/errors.js @@ -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; @@ -20,5 +21,5 @@ FigoError.prototype.toString = function() { }; module.exports = { - FigoError: FigoError + FigoError: FigoError };