full diff: https://github.com/docker/cli/compare/v27.5.1..v28.0.0-rc.1 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
30 lines
589 B
Go
30 lines
589 B
Go
package cli
|
|
|
|
import (
|
|
"strconv"
|
|
)
|
|
|
|
// 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()
|
|
}
|
|
return "exit status " + strconv.Itoa(e.StatusCode)
|
|
}
|
|
|
|
func (e StatusError) Unwrap() error {
|
|
return e.Cause
|
|
}
|