/
error.go
39 lines (32 loc) · 968 Bytes
/
error.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// NOTICE
// This file is copyrighted by Docker under the Apache 2.0 license
// The original can be found here:
// https://github.com/appcelerator/amp/docker/docker/blob/master/cli/error.go
package cli
import (
"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 {
// TODO revisit the idea of command status codes, not useful right now
// return fmt.Sprintf("Status: %s, Code: %d", e.Status, e.StatusCode)
return e.Status
}