error.go 733 B

123456789101112131415161718192021222324252627282930313233
  1. package cli // import "github.com/docker/docker/cli"
  2. import (
  3. "fmt"
  4. "strings"
  5. )
  6. // Errors is a list of errors.
  7. // Useful in a loop if you don't want to return the error right away and you want to display after the loop,
  8. // all the errors that happened during the loop.
  9. type Errors []error
  10. func (errList Errors) Error() string {
  11. if len(errList) < 1 {
  12. return ""
  13. }
  14. out := make([]string, len(errList))
  15. for i := range errList {
  16. out[i] = errList[i].Error()
  17. }
  18. return strings.Join(out, ", ")
  19. }
  20. // StatusError reports an unsuccessful exit by a command.
  21. type StatusError struct {
  22. Status string
  23. StatusCode int
  24. }
  25. func (e StatusError) Error() string {
  26. return fmt.Sprintf("Status: %s, Code: %d", e.Status, e.StatusCode)
  27. }