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

fix(client): fix handling of not found errors #219

Merged
merged 4 commits into from
Oct 20, 2021

Conversation

laurentlp
Copy link
Contributor

This PR fixes an issue where 404 Not Found errors were badly handled.

Since we always access the data property from the response when making an API call, the function must always return an AxiosResponse which wasn't the case with 404s (it returned undefined instead).

Returning { data: undefined } could have been an option, but I opted to create an error handler specific to not found errors so we can reuse it. Also, it makes it clear where we handle those kinds of errors and I find it much more cleaner.

Please, let me know if you have better ideas or any suggestions for improvements!

Also, this makes me think that we should take some time to standardize our response code and make sure that they are all the right ones in each context (e.g. send 404 everywhere a DB call can return empty data and switch from 403 to 401 where it should be the latter)

@laurentlp laurentlp merged commit 025f290 into master Oct 20, 2021
@laurentlp laurentlp deleted the llp_client_handle_404 branch October 20, 2021 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants