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

Handle errors in Request() #485

Merged
merged 3 commits into from Apr 13, 2022
Merged

Handle errors in Request() #485

merged 3 commits into from Apr 13, 2022

Conversation

Morganamilo
Copy link
Contributor

Currently errors like 500 response codes are not checked and don't
return an error.

Request is still broken but may as well push this fix as I've moved to other stuff for the time being.

@Morganamilo
Copy link
Contributor Author

I think the tests may actually be failing for real here. Need to look into it.

My interpretation of RSC19e is that Request() should only return an
error if there's a network error. However it also states the standard
fallback rulles apply.

So we save the response then check it's status. If the status we return
an error so that the fallback functions trigger. If we end up with an
error still after exausting all fallbacks then we return the last req
that succeeded.

This lets us try fallbacks and also return bad requests for the user to
inspect.
The code only falls back when the status code is 500 but gives up right
away if the request failed outright.
@Morganamilo Morganamilo merged commit e966bc2 into main Apr 13, 2022
@Morganamilo Morganamilo deleted the uncheckedstatus branch April 13, 2022 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants