Loading lib/errors.js +9 −3 Original line number Original line Diff line number Diff line 'use strict'; 'use strict'; function RequestError(cause) { function RequestError(cause, options, response) { this.name = 'RequestError'; this.name = 'RequestError'; this.message = String(cause); this.message = String(cause); this.cause = cause; this.cause = cause; this.error = cause; // legacy attribute this.options = options; this.response = response; if (Error.captureStackTrace) { // if required for non-V8 envs - see PR #40 if (Error.captureStackTrace) { // if required for non-V8 envs - see PR #40 Error.captureStackTrace(this); Error.captureStackTrace(this); Loading @@ -16,11 +19,14 @@ RequestError.prototype = Object.create(Error.prototype); RequestError.prototype.constructor = RequestError; RequestError.prototype.constructor = RequestError; function StatusCodeError(statusCode, message) { function StatusCodeError(statusCode, body, options, response) { this.name = 'StatusCodeError'; this.name = 'StatusCodeError'; this.statusCode = statusCode; this.statusCode = statusCode; this.message = statusCode + ' - ' + (JSON && JSON.stringify ? JSON.stringify(message) : message); this.message = statusCode + ' - ' + (JSON && JSON.stringify ? JSON.stringify(body) : body); this.error = body; // legacy attribute this.options = options; this.response = response; if (Error.captureStackTrace) { // if required for non-V8 envs - see PR #40 if (Error.captureStackTrace) { // if required for non-V8 envs - see PR #40 Error.captureStackTrace(this); Error.captureStackTrace(this); Loading lib/rp.js +2 −10 Original line number Original line Diff line number Diff line Loading @@ -57,19 +57,11 @@ function RP$callback(err, response, body) { if (err) { if (err) { self._rp_reject(assign(new errors.RequestError(err), { self._rp_reject(new errors.RequestError(err, self._rp_options, response)); error: err, options: self._rp_options, response: response })); } else if (self._rp_options.simple && !(/^2/.test('' + response.statusCode))) { } else if (self._rp_options.simple && !(/^2/.test('' + response.statusCode))) { self._rp_reject(assign(new errors.StatusCodeError(response.statusCode, body), { self._rp_reject(new errors.StatusCodeError(response.statusCode, body, self._rp_options, response)); error: body, options: self._rp_options, response: response })); } else { } else { if (isFunction(self._rp_options.transform)) { if (isFunction(self._rp_options.transform)) { Loading Loading
lib/errors.js +9 −3 Original line number Original line Diff line number Diff line 'use strict'; 'use strict'; function RequestError(cause) { function RequestError(cause, options, response) { this.name = 'RequestError'; this.name = 'RequestError'; this.message = String(cause); this.message = String(cause); this.cause = cause; this.cause = cause; this.error = cause; // legacy attribute this.options = options; this.response = response; if (Error.captureStackTrace) { // if required for non-V8 envs - see PR #40 if (Error.captureStackTrace) { // if required for non-V8 envs - see PR #40 Error.captureStackTrace(this); Error.captureStackTrace(this); Loading @@ -16,11 +19,14 @@ RequestError.prototype = Object.create(Error.prototype); RequestError.prototype.constructor = RequestError; RequestError.prototype.constructor = RequestError; function StatusCodeError(statusCode, message) { function StatusCodeError(statusCode, body, options, response) { this.name = 'StatusCodeError'; this.name = 'StatusCodeError'; this.statusCode = statusCode; this.statusCode = statusCode; this.message = statusCode + ' - ' + (JSON && JSON.stringify ? JSON.stringify(message) : message); this.message = statusCode + ' - ' + (JSON && JSON.stringify ? JSON.stringify(body) : body); this.error = body; // legacy attribute this.options = options; this.response = response; if (Error.captureStackTrace) { // if required for non-V8 envs - see PR #40 if (Error.captureStackTrace) { // if required for non-V8 envs - see PR #40 Error.captureStackTrace(this); Error.captureStackTrace(this); Loading
lib/rp.js +2 −10 Original line number Original line Diff line number Diff line Loading @@ -57,19 +57,11 @@ function RP$callback(err, response, body) { if (err) { if (err) { self._rp_reject(assign(new errors.RequestError(err), { self._rp_reject(new errors.RequestError(err, self._rp_options, response)); error: err, options: self._rp_options, response: response })); } else if (self._rp_options.simple && !(/^2/.test('' + response.statusCode))) { } else if (self._rp_options.simple && !(/^2/.test('' + response.statusCode))) { self._rp_reject(assign(new errors.StatusCodeError(response.statusCode, body), { self._rp_reject(new errors.StatusCodeError(response.statusCode, body, self._rp_options, response)); error: body, options: self._rp_options, response: response })); } else { } else { if (isFunction(self._rp_options.transform)) { if (isFunction(self._rp_options.transform)) { Loading