summaryrefslogtreecommitdiff
path: root/modules/caddyhttp
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-10-30 21:41:52 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2019-10-30 21:41:52 -0600
commit8d3c64932eddb42f7e5c4549555e9d12a559d552 (patch)
tree58822905ac360ed99d17017e2f8b37bf616fa45f /modules/caddyhttp
parent0dd9243478f765e83c41851e381aa6c5ce2daf3f (diff)
http: Avoid panic if handler errors lack underlying error value
Fixes #2845
Diffstat (limited to 'modules/caddyhttp')
-rw-r--r--modules/caddyhttp/server.go6
1 files changed, 5 insertions, 1 deletions
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),