10 // Error implements the error interface and can represents multiple
11 // errors that occur in the course of a single decode.
16 func (e *Error) Error() string {
17 points := make([]string, len(e.Errors))
18 for i, err := range e.Errors {
19 points[i] = fmt.Sprintf("* %s", err)
24 "%d error(s) decoding:\n\n%s",
25 len(e.Errors), strings.Join(points, "\n"))
28 // WrappedErrors implements the errwrap.Wrapper interface to make this
29 // return value more useful with the errwrap and go-multierror libraries.
30 func (e *Error) WrappedErrors() []error {
35 result := make([]error, len(e.Errors))
36 for i, e := range e.Errors {
37 result[i] = errors.New(e)
43 func appendErrors(errors []string, err error) []string {
44 switch e := err.(type) {
46 return append(errors, e.Errors...)
48 return append(errors, e.Error())