From 72541f1cb81a97466afcdf0a6164367c499a9f81 Mon Sep 17 00:00:00 2001
From: Francis Lavoie <lavofr@gmail.com>
Date: Tue, 23 Aug 2022 01:31:07 -0400
Subject: [PATCH] caddyhttp: Set `http.error.message` to the HandlerError
 message (#4971)

---
 modules/caddyhttp/server.go | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/modules/caddyhttp/server.go b/modules/caddyhttp/server.go
index f8cd61227..73e14757b 100644
--- a/modules/caddyhttp/server.go
+++ b/modules/caddyhttp/server.go
@@ -526,8 +526,9 @@ func (*HTTPErrorConfig) WithError(r *http.Request, err error) *http.Request {
 	if handlerErr, ok := err.(HandlerError); ok {
 		repl.Set("http.error.status_code", handlerErr.StatusCode)
 		repl.Set("http.error.status_text", http.StatusText(handlerErr.StatusCode))
-		repl.Set("http.error.trace", handlerErr.Trace)
 		repl.Set("http.error.id", handlerErr.ID)
+		repl.Set("http.error.trace", handlerErr.Trace)
+		repl.Set("http.error.message", handlerErr.Err.Error())
 	}
 
 	return r