From 18c309b5fa1847a5303a053a4c79d3a395bdd823 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Tue, 25 Jul 2023 09:41:56 -0600 Subject: [PATCH] caddyhttp: Preserve original error (fix #5652) --- modules/caddyhttp/errors.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/caddyhttp/errors.go b/modules/caddyhttp/errors.go index 1538d435..fc8ffbfa 100644 --- a/modules/caddyhttp/errors.go +++ b/modules/caddyhttp/errors.go @@ -15,6 +15,7 @@ package caddyhttp import ( + "errors" "fmt" weakrand "math/rand" "path" @@ -30,7 +31,8 @@ import ( // set will be populated. func Error(statusCode int, err error) HandlerError { const idLen = 9 - if he, ok := err.(HandlerError); ok { + var he HandlerError + if errors.As(err, &he) { if he.ID == "" { he.ID = randString(idLen, true) }