Skip to content

Commit

Permalink
Include internal error in http error handler
Browse files Browse the repository at this point in the history
Signed-off-by: Vishal Rana <vr@labstack.com>
  • Loading branch information
vishr committed Aug 11, 2019
1 parent 09d415c commit ecc01d2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,24 +344,28 @@ func (e *Echo) DefaultHTTPErrorHandler(err error, c Context) {
he, ok := err.(*HTTPError)
if ok {
if he.Internal != nil {
err = fmt.Errorf("%v, %v", err, he.Internal)
if herr, ok := he.Internal.(*HTTPError); ok {
he = herr
}
}
} else {
he = &HTTPError{
Code: http.StatusInternalServerError,
Code: http.StatusInternalServerError,
Message: http.StatusText(http.StatusInternalServerError),
}
}
if e.Debug {
he.Message = err.Error()
} else if m, ok := he.Message.(string); ok {
he.Message = Map{"message": m}
}

// Send response
if !c.Response().Committed {
if c.Request().Method == http.MethodHead { // Issue #608
err = c.NoContent(he.Code)
} else {
err = c.JSON(he.Code, he)
err = c.JSON(he.Code, he.Message)
}
if err != nil {
e.Logger.Error(err)
Expand Down

0 comments on commit ecc01d2

Please sign in to comment.