Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(cli): fix potential panic in traceError if unwrapped err is nil
  • Loading branch information
johnstcn committed Oct 21, 2024
commit c68f8269ce95fe850180bfded94d16fae9448dd9
11 changes: 10 additions & 1 deletion cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Loading