2018-02-05 21:05:59 +00:00
|
|
|
package cli // import "github.com/docker/docker/cli"
|
2016-05-16 15:50:55 +00:00
|
|
|
|
2016-06-23 15:25:51 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
)
|
2016-05-16 15:50:55 +00:00
|
|
|
|
|
|
|
// 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
|
|
|
|
|
2016-06-15 16:17:05 +00:00
|
|
|
func (errList Errors) Error() string {
|
|
|
|
if len(errList) < 1 {
|
2016-05-16 15:50:55 +00:00
|
|
|
return ""
|
|
|
|
}
|
2016-06-15 16:17:05 +00:00
|
|
|
|
|
|
|
out := make([]string, len(errList))
|
|
|
|
for i := range errList {
|
|
|
|
out[i] = errList[i].Error()
|
2016-05-16 15:50:55 +00:00
|
|
|
}
|
2016-06-15 16:17:05 +00:00
|
|
|
return strings.Join(out, ", ")
|
2016-05-16 15:50:55 +00:00
|
|
|
}
|
2016-06-23 15:25:51 +00:00
|
|
|
|
|
|
|
// 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)
|
|
|
|
}
|