1 |
|
2 | export class HTTPError extends Error {
|
3 | constructor(response, request, options) {
|
4 | const code = (response.status || response.status === 0) ? response.status : '';
|
5 | const title = response.statusText || '';
|
6 | const status = `${code} ${title}`.trim();
|
7 | const reason = status ? `status code ${status}` : 'an unknown error';
|
8 | super(`Request failed with ${reason}`);
|
9 | Object.defineProperty(this, "response", {
|
10 | enumerable: true,
|
11 | configurable: true,
|
12 | writable: true,
|
13 | value: void 0
|
14 | });
|
15 | Object.defineProperty(this, "request", {
|
16 | enumerable: true,
|
17 | configurable: true,
|
18 | writable: true,
|
19 | value: void 0
|
20 | });
|
21 | Object.defineProperty(this, "options", {
|
22 | enumerable: true,
|
23 | configurable: true,
|
24 | writable: true,
|
25 | value: void 0
|
26 | });
|
27 | this.name = 'HTTPError';
|
28 | this.response = response;
|
29 | this.request = request;
|
30 | this.options = options;
|
31 | }
|
32 | }
|
33 |
|
\ | No newline at end of file |