diff options
author | Matthew Holt <mholt@users.noreply.github.com> | 2023-07-25 09:41:56 -0600 |
---|---|---|
committer | Matthew Holt <mholt@users.noreply.github.com> | 2023-07-25 09:41:56 -0600 |
commit | 18c309b5fa1847a5303a053a4c79d3a395bdd823 (patch) | |
tree | e29c8ec4d084906df6e2babacd9a15fae71ce49c /modules/caddyhttp | |
parent | e041962b66c45db8baab95b71a65f4c164736684 (diff) |
caddyhttp: Preserve original error (fix #5652)
Diffstat (limited to 'modules/caddyhttp')
-rw-r--r-- | modules/caddyhttp/errors.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/modules/caddyhttp/errors.go b/modules/caddyhttp/errors.go index 1538d43..fc8ffbf 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) } |