File tree Expand file tree Collapse file tree 2 files changed +4
-20
lines changed Expand file tree Collapse file tree 2 files changed +4
-20
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ func (c Chain) Error() string {
34
34
lines := make ([]string , 0 , len (c ))
35
35
// source=<source> <prefix>: <error> tag=value tag2=value2 types=type1,type2
36
36
for i := len (c ) - 1 ; i >= 0 ; i -- {
37
- line := c [i ].Error ()
37
+ line := c [i ].formatError ()
38
38
lines = append (lines , line )
39
39
}
40
40
return strings .Join (lines , "\n " )
@@ -60,17 +60,15 @@ type Link struct {
60
60
Source string
61
61
}
62
62
63
- // Error prints a single Links error
64
- func (l * Link ) Error () string {
63
+ // formatError prints a single Links error
64
+ func (l * Link ) formatError () string {
65
65
line := fmt .Sprintf ("source=%s " , l .Source )
66
66
67
67
if l .Prefix != "" {
68
68
line += l .Prefix + ": "
69
69
}
70
70
71
- if _ , isLink := l .Err .(* Link ); ! isLink {
72
- line += l .Err .Error ()
73
- }
71
+ line += l .Err .Error ()
74
72
75
73
for _ , tag := range l .Tags {
76
74
line += fmt .Sprintf (" %s=%v" , tag .Key , tag .Value )
Original file line number Diff line number Diff line change @@ -46,8 +46,6 @@ func Cause(err error) error {
46
46
switch t := err .(type ) {
47
47
case Chain :
48
48
return t [0 ].Err
49
- case * Link :
50
- return t .Err
51
49
default :
52
50
return err
53
51
}
@@ -66,12 +64,6 @@ func HasType(err error, typ string) bool {
66
64
}
67
65
}
68
66
}
69
- case * Link :
70
- for i := 0 ; i < len (t .Types ); i ++ {
71
- if t .Types [i ] == typ {
72
- return true
73
- }
74
- }
75
67
}
76
68
return false
77
69
}
@@ -87,12 +79,6 @@ func LookupTag(err error, key string) interface{} {
87
79
}
88
80
}
89
81
}
90
- case * Link :
91
- for i := 0 ; i < len (t .Tags ); i ++ {
92
- if t .Tags [i ].Key == key {
93
- return t .Tags [i ].Value
94
- }
95
- }
96
82
}
97
83
return nil
98
84
}
You can’t perform that action at this time.
0 commit comments