-
-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy patherror.go
More file actions
42 lines (34 loc) · 616 Bytes
/
error.go
File metadata and controls
42 lines (34 loc) · 616 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
35
36
37
38
39
40
41
42
package pget
import "github.com/pkg/errors"
type causer interface {
Cause() error
}
type ignore struct {
err error
}
func makeIgnoreErr() ignore {
return ignore{
err: errors.New("this is ignore message"),
}
}
// Error for options: version, usage
func (i ignore) Error() string {
return i.err.Error()
}
func (i ignore) Cause() error {
return i.err
}
// errTop get important message from wrapped error message
func errTop(err error) error {
for e := err; e != nil; {
switch e.(type) {
case ignore:
return nil
case causer:
e = e.(causer).Cause()
default:
return e
}
}
return nil
}