Skip to content

Commit

Permalink
feat: improve restConnector error handling (#650)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoh authored Jan 9, 2025
1 parent 0850b1e commit 79e0218
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/core/src/connectors/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@ export function restConnector(uri = 'http://localhost:3000/') {
body: JSON.stringify(query)
});


const res = await req;

if (!res.ok) {
throw new Error(`Query failed with HTTP status ${res.status}: ${await res.text()}`);
}

return query.type === 'exec' ? req
: query.type === 'arrow' ? decodeIPC(await (await req).arrayBuffer())
: (await req).json();
: query.type === 'arrow' ? decodeIPC(await res.arrayBuffer())
: res.json();
}
};
}

0 comments on commit 79e0218

Please sign in to comment.