Skip to content

Commit

Permalink
handle text rejections
Browse files Browse the repository at this point in the history
  • Loading branch information
vigneshshanmugam committed Apr 30, 2024
1 parent 4dd1ed8 commit 1ec5c84
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/push/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ export async function handleError(
throw formatNotFoundError(url, await body.text());
} else if (!ok(statusCode)) {
let parsed: APIError;
const resp = await body.text();
try {
const resp = await body.text();
parsed = JSON.parse(resp) as APIError;
} catch (e) {
throw formatAPIError(statusCode, 'unexpected non-JSON error', resp);
throw formatAPIError(statusCode, 'unexpected error', e.message);
}
throw formatAPIError(statusCode, parsed.error, parsed.message);
}
Expand Down

0 comments on commit 1ec5c84

Please sign in to comment.