summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/labstack/echo/v4/echo.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/labstack/echo/v4/echo.go')
-rw-r--r--vendor/github.com/labstack/echo/v4/echo.go28
1 files changed, 18 insertions, 10 deletions
diff --git a/vendor/github.com/labstack/echo/v4/echo.go b/vendor/github.com/labstack/echo/v4/echo.go
index 406e806b..df5d3584 100644
--- a/vendor/github.com/labstack/echo/v4/echo.go
+++ b/vendor/github.com/labstack/echo/v4/echo.go
@@ -241,7 +241,7 @@ const (
const (
// Version of Echo
- Version = "4.4.0"
+ Version = "4.6.1"
website = "https://echo.labstack.com"
// http://patorjk.com/software/taag/#p=display&f=Small%20Slant&t=Echo
banner = `
@@ -357,7 +357,17 @@ func (e *Echo) Routers() map[string]*Router {
// DefaultHTTPErrorHandler is the default HTTP error handler. It sends a JSON response
// with status code.
+//
+// NOTE: In case errors happens in middleware call-chain that is returning from handler (which did not return an error).
+// When handler has already sent response (ala c.JSON()) and there is error in middleware that is returning from
+// handler. Then the error that global error handler received will be ignored because we have already "commited" the
+// response and status code header has been sent to the client.
func (e *Echo) DefaultHTTPErrorHandler(err error, c Context) {
+
+ if c.Response().Committed {
+ return
+ }
+
he, ok := err.(*HTTPError)
if ok {
if he.Internal != nil {
@@ -384,15 +394,13 @@ func (e *Echo) DefaultHTTPErrorHandler(err error, c Context) {
}
// Send response
- if !c.Response().Committed {
- if c.Request().Method == http.MethodHead { // Issue #608
- err = c.NoContent(he.Code)
- } else {
- err = c.JSON(code, message)
- }
- if err != nil {
- e.Logger.Error(err)
- }
+ if c.Request().Method == http.MethodHead { // Issue #608
+ err = c.NoContent(he.Code)
+ } else {
+ err = c.JSON(code, message)
+ }
+ if err != nil {
+ e.Logger.Error(err)
}
}