Browse Source

Set HTTP error handler

master
Simon Ser 4 years ago
parent
commit
23e3e85251
No known key found for this signature in database GPG Key ID: FDE7BE0E88F5E48
1 changed files with 11 additions and 0 deletions
  1. +11
    -0
      server.go

+ 11
- 0
server.go View File

@@ -162,6 +162,17 @@ func New(imapURL string) *echo.Echo {
e.Logger.Fatal(err)
}

e.HTTPErrorHandler = func(err error, c echo.Context) {
code := http.StatusInternalServerError
if he, ok := err.(*echo.HTTPError); ok {
code = he.Code
} else {
c.Logger().Error(err)
}
// TODO: hide internal errors
c.String(code, err.Error())
}

e.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
return func(ectx echo.Context) error {
ctx := &context{Context: ectx, server: s}


Loading…
Cancel
Save