From 8d3c64932eddb42f7e5c4549555e9d12a559d552 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Wed, 30 Oct 2019 21:41:52 -0600 Subject: http: Avoid panic if handler errors lack underlying error value Fixes #2845 --- modules/caddyhttp/server.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'modules/caddyhttp') diff --git a/modules/caddyhttp/server.go b/modules/caddyhttp/server.go index 34c2b54..255b996 100644 --- a/modules/caddyhttp/server.go +++ b/modules/caddyhttp/server.go @@ -368,7 +368,11 @@ type ServerLogConfig struct { func errLogValues(err error) (status int, msg string, fields []zapcore.Field) { if handlerErr, ok := err.(HandlerError); ok { status = handlerErr.StatusCode - msg = handlerErr.Err.Error() + if handlerErr.Err == nil { + msg = err.Error() + } else { + msg = handlerErr.Err.Error() + } fields = []zapcore.Field{ zap.Int("status", handlerErr.StatusCode), zap.String("err_id", handlerErr.ID), -- cgit v1.2.3