Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
http: Avoid panic if handler errors lack underlying error value
Fixes #2845
Matthew Holt committed
Oct 30, 2019 at 21:41 UTC
8d3c64932eddb42f7e5c4549555e9d12a559d552
1 file changed
+5
-1
modules/caddyhttp/server.go
+5
-1
@@ -368,7 +368,11 @@ type ServerLogConfig struct {
368
func errLogValues(err error) (status int, msg string, fields []zapcore.Field) {
369
if handlerErr, ok := err.(HandlerError); ok {
370
status = handlerErr.StatusCode
371
- msg = handlerErr.Err.Error()
371
+ if handlerErr.Err == nil {
372
+ msg = err.Error()
373
+ } else {
374
+ msg = handlerErr.Err.Error()
375
+ }
376
fields = []zapcore.Field{
377
zap.Int("status", handlerErr.StatusCode),
378
zap.String("err_id", handlerErr.ID),