{koji,worker}/server: log errors returned from handlers

Previously, we had no clue what errors were catched by the default echo's
error handler. Thus, in the case of an error, we were basically blind. Let's
log all errors so we can investigate them later.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
Ondřej Budai 2020-11-30 09:20:51 +01:00 committed by Ondřej Budai
parent cbc9082fac
commit e10a7f1ccc
2 changed files with 12 additions and 0 deletions

View file

@ -46,6 +46,12 @@ func (s *Server) Handler(path string) http.Handler {
e.Binder = binder{}
e.StdLogger = s.logger
// log errors returned from handlers
e.HTTPErrorHandler = func(err error, c echo.Context) {
log.Println(c.Path(), c.QueryParams().Encode(), err.Error())
e.DefaultHTTPErrorHandler(err, c)
}
api.RegisterHandlers(e.Group(path), &apiHandlers{s})
return e

View file

@ -62,6 +62,12 @@ func (s *Server) Handler() http.Handler {
e.Binder = binder{}
e.StdLogger = s.logger
// log errors returned from handlers
e.HTTPErrorHandler = func(err error, c echo.Context) {
log.Println(c.Path(), c.QueryParams().Encode(), err.Error())
e.DefaultHTTPErrorHandler(err, c)
}
handler := apiHandlers{
server: s,
}