1 /** 2 * @fileOverview ResponseError class definition 3 */ 4 5 /** 6 * ResponseError is a wrapper for request errors, this makes it easier to pass 7 * an error to the callbacks of the async functions that still retain their 8 * extra contextual information passed into the arguments of requests's error 9 * handler 10 * 11 * @class HTTP Response Error 12 * @constructor 13 * @param {object} response Response HTTP client 14 * @param {object} request Request description 15 */ 16 var ResponseError = function (response, request) { 17 /** 18 * The error message. 19 */ 20 this.message = 'ResponseError: ' + response.status; 21 22 /** 23 * Actual response from the server. 24 */ 25 this.response = response; 26 27 /** 28 * Status of the response. 29 */ 30 this.status = response.status; 31 32 /** 33 * The request. 34 */ 35 this.request = request; 36 }; 37 38 ResponseError.prototype = new Error(); 39 40 module.exports = ResponseError; 41