From c68f8269ce95fe850180bfded94d16fae9448dd9 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Mon, 21 Oct 2024 14:53:11 +0100 Subject: [PATCH] fix(cli): fix potential panic in traceError if unwrapped err is nil --- cli/root.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cli/root.go b/cli/root.go index 5d9ed5590f3a3..f0bae8ff75adb 100644 --- a/cli/root.go +++ b/cli/root.go @@ -1116,7 +1116,16 @@ func formatCoderSDKError(from string, err *codersdk.Error, opts *formatOpts) str //nolint:errorlint func traceError(err error) string { if uw, ok := err.(interface{ Unwrap() error }); ok { - a, b := err.Error(), uw.Unwrap().Error() + var a, b string + if err != nil { + a = err.Error() + } + if uw != nil { + uwerr := uw.Unwrap() + if uwerr != nil { + b = uwerr.Error() + } + } c := strings.TrimSuffix(a, b) return c } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy