Skip to content

Commit d754fd8

Browse files
committed
conditional, do not print empty string
1 parent 2ac5c17 commit d754fd8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

cli/root.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,10 @@ func formatMultiError(from string, multi []error, opts *formatOpts) string {
11091109

11101110
// Write errors out
11111111
var str strings.Builder
1112-
traceMsg := fmt.Sprintf("Trace=[%s])", from)
1112+
var traceMsg string
1113+
if from != "" {
1114+
traceMsg = fmt.Sprintf("Trace=[%s])", from)
1115+
}
11131116
_, _ = str.WriteString(pretty.Sprint(headLineStyle(), fmt.Sprintf("%d errors encountered: %s", len(multi), traceMsg)))
11141117
for i, errStr := range errorStrings {
11151118
// Indent each error
@@ -1159,8 +1162,10 @@ func formatCoderSDKError(from string, err *codersdk.Error, opts *formatOpts) str
11591162
_, _ = str.WriteString("\n")
11601163
}
11611164
// Always include this trace. Users can ignore this.
1162-
_, _ = str.WriteString(pretty.Sprint(headLineStyle(), fmt.Sprintf("Trace=[%s]", from)))
1163-
_, _ = str.WriteString("\n")
1165+
if from != "" {
1166+
_, _ = str.WriteString(pretty.Sprint(headLineStyle(), fmt.Sprintf("Trace=[%s]", from)))
1167+
_, _ = str.WriteString("\n")
1168+
}
11641169

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

0 commit comments

Comments
 (0)