Improve handling of httperrors.Error
Closed this issue · 1 comments
morremeyer commented
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 commented
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