forked from golang/dep
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.go
More file actions
34 lines (29 loc) · 690 Bytes
/
error.go
File metadata and controls
34 lines (29 loc) · 690 Bytes
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
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package gps
import (
"bytes"
"fmt"
)
type errorSlice []error
func (errs errorSlice) Error() string {
var buf bytes.Buffer
fmt.Fprintln(&buf)
for i, err := range errs {
fmt.Fprintf(&buf, "\t(%d) %s\n", i+1, err)
}
return buf.String()
}
func (errs errorSlice) Format(f fmt.State, c rune) {
fmt.Fprintln(f)
for i, err := range errs {
if ferr, ok := err.(fmt.Formatter); ok {
fmt.Fprintf(f, "\t(%d) ", i+1)
ferr.Format(f, c)
fmt.Fprint(f, "\n")
} else {
fmt.Fprintf(f, "\t(%d) %s\n", i+1, err)
}
}
}