-
Notifications
You must be signed in to change notification settings - Fork 2
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
[Fetch] Throws Response Error on http failure #1
Comments
Next Steps and TODOs
|
Part of this is thinking about if it's just worth switching to Axios. It's trivial to swap out the http client for the generator. This project is a toy and an exercise in Not Invented Here, as is the whole spacetraders game for me. So using native Fetch in Node 18 and writing code to enrich it's experience without installing deps is fun. But, the openapi generator has already made some choices for us in terms of enriching fetch, and those were NIH. So let's not cling too dearly to the idea of writing a bunch of custom stuff unless it provides value. Axios handles a lot of this stuff very well, but I'm trying to find a balance between having fun working with new tools (Node Native Fetch) and creating a useful library for myself and others. All that said, the Axios client still can't type error returns, we need to fix that upstream at the Spacetraders OpenAPI Spec |
Handling Errors in @spacejunk/airlock
This issue is for tracking a few concerns related to error handling in the
@spacejunk/airlock
package while using Fetch as the http client:typescript-fetch
generator throws aResponseError
for status codes above 299, which is a departure from the pure Fetch behavior. This choice is not intentional but is imposed by the generator's source, which still needs to be located.response.json()
. The generator's runtime handlesresponse.json()
for successful requests, so it's unexpected for users to have this magic removed for error responses.Here's sample TypeScript code to illustrate the error handling:
The text was updated successfully, but these errors were encountered: