HTTPError: also include the associated Request object

This commit is contained in:
Alex Gleason 2024-10-12 14:55:34 -05:00
parent 943c5fddee
commit 5a0713a02e
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 4 additions and 2 deletions

View File

@ -1,10 +1,12 @@
export class HTTPError extends Error {
response: Response;
request: Request;
constructor(response: Response) {
constructor(response: Response, request: Request) {
super(response.statusText);
this.response = response;
this.request = request;
}
}

View File

@ -84,7 +84,7 @@ export class MastodonClient {
const response = await this.fetch(request);
if (!response.ok) {
throw new HTTPError(response);
throw new HTTPError(response, request);
}
return response;