2016-05-16 11:50:55 -04:00
|
|
|
package cli
|
|
|
|
|
2016-06-15 12:17:05 -04:00
|
|
|
import "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
|
|
|
}
|