mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
4f0d95fa6e
Signed-off-by: Daniel Nephin <dnephin@docker.com>
33 lines
733 B
Go
33 lines
733 B
Go
package cli // import "github.com/docker/docker/cli"
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// Errors is a list of errors.
|
|
// Useful in a loop if you don't want to return the error right away and you want to display after the loop,
|
|
// all the errors that happened during the loop.
|
|
type Errors []error
|
|
|
|
func (errList Errors) Error() string {
|
|
if len(errList) < 1 {
|
|
return ""
|
|
}
|
|
|
|
out := make([]string, len(errList))
|
|
for i := range errList {
|
|
out[i] = errList[i].Error()
|
|
}
|
|
return strings.Join(out, ", ")
|
|
}
|
|
|
|
// StatusError reports an unsuccessful exit by a command.
|
|
type StatusError struct {
|
|
Status string
|
|
StatusCode int
|
|
}
|
|
|
|
func (e StatusError) Error() string {
|
|
return fmt.Sprintf("Status: %s, Code: %d", e.Status, e.StatusCode)
|
|
}
|