Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | 138x 138x 138x 138x 62x 1x 11x 11x 11x 11x | import defined from "./defined.js";
import parseResponseHeaders from "./parseResponseHeaders.js";
/**
* An event that is raised when a request encounters an error.
*
* @constructor
* @alias RequestErrorEvent
*
* @param {number} [statusCode] The HTTP error status code, such as 404.
* @param {object} [response] The response included along with the error.
* @param {string|object} [responseHeaders] The response headers, represented either as an object literal or as a
* string in the format returned by XMLHttpRequest's getAllResponseHeaders() function.
*/
function RequestErrorEvent(statusCode, response, responseHeaders) {
/**
* The HTTP error status code, such as 404. If the error does not have a particular
* HTTP code, this property will be undefined.
*
* @type {number}
*/
this.statusCode = statusCode;
/**
* The response included along with the error. If the error does not include a response,
* this property will be undefined.
*
* @type {object}
*/
this.response = response;
/**
* The headers included in the response, represented as an object literal of key/value pairs.
* If the error does not include any headers, this property will be undefined.
*
* @type {object}
*/
this.responseHeaders = responseHeaders;
if (typeof this.responseHeaders === "string") {
this.responseHeaders = parseResponseHeaders(this.responseHeaders);
}
}
/**
* Creates a string representing this RequestErrorEvent.
* @memberof RequestErrorEvent
*
* @returns {string} A string representing the provided RequestErrorEvent.
*/
RequestErrorEvent.prototype.toString = function () {
let str = "Request has failed.";
Eif (defined(this.statusCode)) {
str += ` Status Code: ${this.statusCode}`;
}
return str;
};
export default RequestErrorEvent;
|