-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhttp-error.ts
More file actions
49 lines (41 loc) · 999 Bytes
/
http-error.ts
File metadata and controls
49 lines (41 loc) · 999 Bytes
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
import { HttpRequest } from '../client';
import { HttpStatusCode } from '../enum';
export class HttpError<HttpResponseT, HttpRequestBodyT> extends Error {
/**
* The http status code.
*/
status?: HttpStatusCode;
/**
* The http statsu text.
*/
statusText?: string;
/**
* The stringified response body.
*/
response?: HttpResponseT;
/**
* The request info.
*/
request?: HttpRequest<HttpRequestBodyT>;
/**
* The initial error that was catched.
*/
nativeError?: unknown;
constructor(
message: string,
status?: HttpStatusCode,
requestInfo?: HttpRequest<HttpRequestBodyT>,
statusText?: string,
response?: HttpResponseT,
nativeError?: unknown
) {
super(message);
this.status = status;
this.request = requestInfo;
this.statusText = statusText;
this.response = response;
this.nativeError = nativeError;
// Set the prototype explicitly.
Object.setPrototypeOf(this, HttpError.prototype);
}
}