Lower level log message for recovery handler
@@ -25,11 +25,12 @@ func NotFound(w http.ResponseWriter, r *http.Request) {
func RecoveryHandler(w http.ResponseWriter, r *http.Request, err interface{}) {
switch internalErr := err.(type) {
case *errors.Error:
- log.Error(internalErr.Error())
- response.JSON(w, internalErr.Code, internalErr)
- case error:
- jsonErr := errors.New(http.StatusInternalServerError, internalErr.Error())
- response.JSON(w, jsonErr.Code, jsonErr)
+ log.WithFields(log.Fields{"code": internalErr.Code, "error": internalErr.Error()}).
+ Warning("Internal error hadled")
+ response.JSON(w, internalErr.Code, internalErr.Error())
+ default:
+ log.WithField("error", err).Error("Internal server error handled")
+ response.JSON(w, http.StatusInternalServerError, err)
}
}
