MCPcopy Index your code
hub / github.com/coder/coder / formatRunCommandError

Function formatRunCommandError

cli/root.go:1444–1460  ·  view source on GitHub ↗

formatRunCommandError are cli command errors. This kind of error is very broad, as it contains all errors that occur when running a command. If you know the error is something else, like a codersdk.Error, make a new formatter and add it to cliHumanFormatError function.

(err *serpent.RunCommandError, opts *formatOpts)

Source from the content-addressed store, hash-verified

1442// If you know the error is something else, like a codersdk.Error, make a new
1443// formatter and add it to cliHumanFormatError function.
1444func formatRunCommandError(err *serpent.RunCommandError, opts *formatOpts) string {
1445 var str strings.Builder
1446 _, _ = str.WriteString(pretty.Sprint(headLineStyle(),
1447 fmt.Sprintf(
1448 `Encountered an error running %q, see "%s --help" for more information`,
1449 err.Cmd.FullName(), err.Cmd.FullName())))
1450 _, _ = str.WriteString(pretty.Sprint(headLineStyle(), "\nerror: "))
1451
1452 msgString, special := cliHumanFormatError("", err.Err, opts)
1453 if special {
1454 _, _ = str.WriteString(msgString)
1455 } else {
1456 _, _ = str.WriteString(pretty.Sprint(tailLineStyle(), msgString))
1457 }
1458
1459 return str.String()
1460}
1461
1462// formatCoderSDKError come from API requests. In verbose mode, add the
1463// request debug information.

Callers 1

cliHumanFormatErrorFunction · 0.85

Calls 6

headLineStyleFunction · 0.85
cliHumanFormatErrorFunction · 0.85
tailLineStyleFunction · 0.85
WriteStringMethod · 0.80
FullNameMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected