Closed tangx closed 2 years ago
https://github.com/go-jarvis/rum-gonic/issues/2
// extractError return http status code and error message
// if err is not a status error, try to return statuserrors status code
// and error message.
func extractError(err error) (code int, msg string) {
if err == nil {
return http.StatusOK, ""
}
if e, ok := err.(statuserrors.StatusError); ok {
return e.StatusCode(), err.Error()
}
sterr := statuserrors.New(statuserrors.StatusUnknownError, err.Error())
return statuserrors.StatusUnknownError, sterr.Error()
}
output error handle logic is ugly https://github.com/go-jarvis/rum-gonic/blob/master/rum/group.go#L150
try to use statuserrors to prove it