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)
| 1442 | // If you know the error is something else, like a codersdk.Error, make a new |
| 1443 | // formatter and add it to cliHumanFormatError function. |
| 1444 | func 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. |
no test coverage detected