Skip to content

chore: handle errors in wsproxy server for cli using buildinfo #11584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jan 11, 2024
Prev Previous commit
conditional, do not print empty string
  • Loading branch information
Emyrk committed Jan 11, 2024
commit d754fd8a30e566dc21ed8ac34647b51a2265ad66
11 changes: 8 additions & 3 deletions cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,10 @@ func formatMultiError(from string, multi []error, opts *formatOpts) string {

// Write errors out
var str strings.Builder
traceMsg := fmt.Sprintf("Trace=[%s])", from)
var traceMsg string
if from != "" {
traceMsg = fmt.Sprintf("Trace=[%s])", from)
}
_, _ = str.WriteString(pretty.Sprint(headLineStyle(), fmt.Sprintf("%d errors encountered: %s", len(multi), traceMsg)))
for i, errStr := range errorStrings {
// Indent each error
Expand Down Expand Up @@ -1159,8 +1162,10 @@ func formatCoderSDKError(from string, err *codersdk.Error, opts *formatOpts) str
_, _ = str.WriteString("\n")
}
// Always include this trace. Users can ignore this.
_, _ = str.WriteString(pretty.Sprint(headLineStyle(), fmt.Sprintf("Trace=[%s]", from)))
_, _ = str.WriteString("\n")
if from != "" {
_, _ = str.WriteString(pretty.Sprint(headLineStyle(), fmt.Sprintf("Trace=[%s]", from)))
_, _ = str.WriteString("\n")
}

_, _ = str.WriteString(pretty.Sprint(headLineStyle(), err.Message))
if err.Helper != "" {
Expand Down