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

How to handle errors in API? #195

Open
pontus opened this issue Dec 14, 2020 · 3 comments
Open

How to handle errors in API? #195

pontus opened this issue Dec 14, 2020 · 3 comments
Labels

Comments

@pontus
Copy link
Contributor

pontus commented Dec 14, 2020

How do we want to handle errors from the API, e.g. signal through HTTP codes (e.g. 403), an empty answer or always do json with a status that is always filled in?

@HenrikeW
Copy link
Contributor

HenrikeW commented May 5, 2021

When working on the frontend, I think it's really helpful to get proper status codes for different types of errors. When I'm still working on the code, I also appreciate if there is some error message sent in the json response that indicates what went wrong. That's more for my own purpose though. I don't show these API-messages to the user but rather have a separate message to the user in the frontend-code. That can be due to language reasons (API sends message in English, website is in Swedish) or because I want to phrase it in a nicer/more helpful way.

@pontus
Copy link
Contributor Author

pontus commented May 5, 2021

Yes, this was probably unclear.

Right now, I think there's a mix; some endpoints return errors akin to jsonapi, some set the return code indicating error on error or return value and some return an empty/null JSON object on error (but a 200). There should definitely be sensible return codes, no matter how we pass them.

@jhagberg jhagberg reopened this Sep 24, 2021
@jhagberg
Copy link
Collaborator

Refactor standardize the way error propagation in backend,

@jhagberg jhagberg added the V2 label Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants