Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add's more descriptive error messages for 429 errors and other errors with no body #1082

Merged
merged 5 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/soft-files-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@osdk/shared.net.fetch": patch
---

Adds better error messages for 429 errors
8 changes: 5 additions & 3 deletions packages/shared.net.fetch/src/createFetchOrThrow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ export function createFetchOrThrow(fetchFn: typeof fetch = fetch) {
try {
body = await response.json();
} catch (e) {
throw convertError(
e,
"A network error occurred while reading response",
throw new PalantirApiError(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine since we already know we're in an error state. The JSON body being unparseable isn't an error here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, all thats missing is actually passing the status code as the forth argument

`Failed to fetch ${response.status} ${response.statusText}`,
"UNKNOWN",
undefined,
response.status,
);
}

Expand Down
Loading