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