diff options
-rw-r--r-- | modules/caddyhttp/server.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/modules/caddyhttp/server.go b/modules/caddyhttp/server.go index d5be1e1..cff0f2e 100644 --- a/modules/caddyhttp/server.go +++ b/modules/caddyhttp/server.go @@ -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 { |