cvanloo / rmsgo

Remote Storage implementation in Go
The Unlicense
1 stars 0 forks source link

r: move error handling logic a bit (but not too far) outside of requset handlers #19

Closed cvanloo closed 1 month ago

cvanloo commented 1 month ago

This defines a HandlerWithError adapter to allow requests to return errors instead of having to handle error cases themselves.

Instead of having a specific HttpError type, this is now an interface with a single RespondError method. (The interface is called ErrorResponder, there is a new HttpError type that can be used to compose more specific types.)

There are custom HttpError implementations for specific error cases, so that the error handling logic can be moved out of the request handlers and into the respective implementations of RespondError.

In the future error responses should be RFC9457 compliant (see #3).

ref: #17