You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// ErrorWithStatus is an interface that can be implemented by an error to provide// additional information about the error.typeErrorWithStatusinterface {
errorStatusCode() int
}
However in order to supply a user defined error the user has to supply something like this:
If you remove the Unwrap this will still compile but it will return this:
400 Bad Request:
Vs
400 Bad Request: <the err>
Unwrap is requited so errors.As can infer the type which we want to always be HTTPError.
However, this code is somewhat brittle, maybe we look at the overall design of custom errors. It feels bad to say here is the interface we need you to adhere too, but basically they have to implement Unwrap always as: func (e MyError) Unwrap() error { return fuego.HTTPError(e) }. I do kinda like that we want everything to be HTTPError as does enforce users to adhere too: RFC 9457. Maybe we just update the docs and explicitly explain that Unwrap must be func (e MyError) Unwrap() error { return fuego.HTTPError(e) } or something along those lines? 🤷
Looking for overall thoughts.
P.S -- I could just be completely missing how to properly do this 😅
The text was updated successfully, but these errors were encountered:
The current interface is:
However in order to supply a user defined error the user has to supply something like this:
If you remove the
Unwrap
this will still compile but it will return this:Vs
Unwrap is requited so
errors.As
can infer the type which we want to always beHTTPError
.However, this code is somewhat brittle, maybe we look at the overall design of custom errors. It feels bad to say here is the interface we need you to adhere too, but basically they have to implement Unwrap always as:
func (e MyError) Unwrap() error { return fuego.HTTPError(e) }
. I do kinda like that we want everything to beHTTPError
as does enforce users to adhere too: RFC 9457. Maybe we just update the docs and explicitly explain thatUnwrap
must befunc (e MyError) Unwrap() error { return fuego.HTTPError(e) }
or something along those lines? 🤷Looking for overall thoughts.
P.S -- I could just be completely missing how to properly do this 😅
The text was updated successfully, but these errors were encountered: