mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-27 06:03:48 +03:00
caddyhttp: Return error if error handling error
Before, if there was an error in the error handler, we would not write a status code, which resulted in Go writing a 200 for us by default, which does not make sense when there's an error. Now we write the second error's status if available, otherwise 500.
This commit is contained in:
parent
1438e4dbc8
commit
349457cc1b
1 changed files with 5 additions and 0 deletions
|
@ -247,6 +247,11 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
zap.String("msg", errMsg),
|
||||
}, errFields...)
|
||||
logger.Error("error handling handler error", errFields...)
|
||||
if handlerErr, ok := err.(HandlerError); ok {
|
||||
w.WriteHeader(handlerErr.StatusCode)
|
||||
} else {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if errStatus >= 500 {
|
||||
|
|
Loading…
Reference in a new issue