Skip to content

Commit 18a6919

Browse files
committed
chore: add throw on non ok responses
1 parent 5ca31e7 commit 18a6919

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

packages/wallet-sdk/src/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ export interface HubInfo {
4242

4343
export const getHubInfo = async (gaiaHubUrl: string, fetchFn: FetchFn = createFetchFn()) => {
4444
const response = await fetchFn(`${gaiaHubUrl}/hub_info`);
45+
if (!response.ok) throw new Error('Failed to fetch hub info');
46+
4547
const data: HubInfo = await response.json();
4648
return data;
4749
};

packages/wallet-sdk/tests/models/account.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ describe(makeAuthResponse.name, () => {
152152
fetchMock.mockImplementationOnce(() => Promise.reject(new Error('Request timeout'))),
153153
opts: { scopes: ['read_write'] },
154154
},
155+
{
156+
mock: () => fetchMock.mockResponseOnce('Too Many Requests', { status: 429 }),
157+
opts: {},
158+
},
155159
];
156160
test.each(TEST_CASES)(makeAuthResponse.name, async ({ mock, opts }) => {
157161
mock();

0 commit comments

Comments
 (0)