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

Improve handling of httperrors.Error #874

Closed
morremeyer opened this issue Dec 1, 2023 · 1 comment · Fixed by #965
Closed

Improve handling of httperrors.Error #874

morremeyer opened this issue Dec 1, 2023 · 1 comment · Fixed by #965
Labels
development Things that support development of the software

Comments

@morremeyer
Copy link
Member

The backend should handle errors as the error type if possible. With the current approach, a lot of code is duplicated.

See https://go.dev/doc/faq#nil_error for details.
However, we also want to transport the HTTP status code. This needs some more thinking and research.

It might be possible to have a generic handler function for the errors that takes the Response type as parameter via a suitable interface and can then return the correct response. With that, the handling code could possibly be much shorter.

@morremeyer morremeyer added the development Things that support development of the software label Dec 1, 2023
@morremeyer
Copy link
Member Author

We can't use the error type in response structs since an error marshals to {}, see golang/go#5161.

Possible solution: https://go.dev/play/p/NrtoYsGzij

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Things that support development of the software
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant