summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorFrancis Lavoie <lavofr@gmail.com>2022-08-23 10:17:46 -0400
committerGitHub <noreply@github.com>2022-08-23 08:17:46 -0600
commita22c08a6385772861173f21ebab3ac0b63796402 (patch)
tree20a080d4d8d0dded029ff7e3663fa8385b5ac966 /modules
parent72541f1cb81a97466afcdf0a6164367c499a9f81 (diff)
caddyhttp: Fix for nil `handlerErr.Err` (#4977)
Diffstat (limited to 'modules')
-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 73e1475..be59184 100644
--- a/modules/caddyhttp/server.go
+++ b/modules/caddyhttp/server.go
@@ -528,7 +528,11 @@ func (*HTTPErrorConfig) WithError(r *http.Request, err error) *http.Request {
repl.Set("http.error.status_text", http.StatusText(handlerErr.StatusCode))
repl.Set("http.error.id", handlerErr.ID)
repl.Set("http.error.trace", handlerErr.Trace)
- repl.Set("http.error.message", handlerErr.Err.Error())
+ if handlerErr.Err != nil {
+ repl.Set("http.error.message", handlerErr.Err.Error())
+ } else {
+ repl.Set("http.error.message", http.StatusText(handlerErr.StatusCode))
+ }
}
return r