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
Have you thought of using a different error struct for internal errors (e.g. ErrUnsupported, ErrBadParameter, ErrUnknownTag)?
One use case where this may be handy is to decide if I send a http.StatusInternalServerError or a http.StatusBadRequest or maybe even do a panic because of wrong validation settings.
The text was updated successfully, but these errors were encountered:
func HandlerFunc(w http.ResponseWriter, r *http.Request) {
// some error from validator
var err error
switch t := err.(type) {
case validator.ValidationError:
http.Error(w, err.Error(), http.StatusBadRequest)
case validator.RuntimeError:
http.Error(w, err.Error(), http.StatusInternalServerError)
}
}
But @robteix must decide if this is a breaking change or not. I personally would consider it as one as people may do error checks agains ErrUnknownTag or something.
Hello Roberto!
Have you thought of using a different error struct for internal errors (e.g.
ErrUnsupported
,ErrBadParameter
,ErrUnknownTag
)?One use case where this may be handy is to decide if I send a
http.StatusInternalServerError
or ahttp.StatusBadRequest
or maybe even do a panic because of wrong validation settings.The text was updated successfully, but these errors were encountered: