docker-cli/cli/error.go
Alano Terblanche 0cff340983
cmd/docker: do not print error status on exec/run
Co-authored-by: Fabio Pugliese Ornellas <fabio.ornellas@gmail.com>
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
2025-02-21 12:55:57 +01:00

28 lines
642 B
Go

package cli
// StatusError reports an unsuccessful exit by a command.
type StatusError struct {
Cause error
Status string
StatusCode int
}
// Error formats the error for printing. If a custom Status is provided,
// it is returned as-is, otherwise it generates a generic error-message
// based on the StatusCode.
func (e StatusError) Error() string {
if e.Status != "" {
return e.Status
}
if e.Cause != nil {
return e.Cause.Error()
}
// we don't want to set a default message here,
// some commands might want to be explicit about the error message
return ""
}
func (e StatusError) Unwrap() error {
return e.Cause
}