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);