HTTPError: also include the associated Request object
This commit is contained in:
parent
943c5fddee
commit
5a0713a02e
|
@ -1,10 +1,12 @@
|
||||||
export class HTTPError extends Error {
|
export class HTTPError extends Error {
|
||||||
|
|
||||||
response: Response;
|
response: Response;
|
||||||
|
request: Request;
|
||||||
|
|
||||||
constructor(response: Response) {
|
constructor(response: Response, request: Request) {
|
||||||
super(response.statusText);
|
super(response.statusText);
|
||||||
this.response = response;
|
this.response = response;
|
||||||
|
this.request = request;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -84,7 +84,7 @@ export class MastodonClient {
|
||||||
const response = await this.fetch(request);
|
const response = await this.fetch(request);
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new HTTPError(response);
|
throw new HTTPError(response, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
|
Loading…
Reference in New Issue