From 5dc0bce95ffe2679e5d25f6b323fe1303236a4c2 Mon Sep 17 00:00:00 2001 From: Nicolai Mainiero Date: Thu, 19 Mar 2015 16:47:07 +0100 Subject: [PATCH] Improved Error types to work in browsers without v8 engine --- lib/errors.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/errors.js b/lib/errors.js index 3e1a654..dbd66fc 100644 --- a/lib/errors.js +++ b/lib/errors.js @@ -7,7 +7,11 @@ function RequestError(cause) { this.message = String(cause); this.cause = cause; - Error.captureStackTrace(this); + if(Error.captureStackTrace){ + Error.captureStackTrace(this); + } else { + Error.call(this); + } } RequestError.prototype = Object.create(Error.prototype); @@ -20,7 +24,11 @@ function StatusCodeError(statusCode, message) { this.statusCode = statusCode; this.message = statusCode + ' - ' + message; - Error.captureStackTrace(this); + if(Error.captureStackTrace){ + Error.captureStackTrace(this); + } else { + Error.call(this); + } } StatusCodeError.prototype = Object.create(Error.prototype);