Skip to content

Commit 129cd49

Browse files
author
Dean Karn
committed
fix error handling, was recursively printing errors
1 parent 7a5a373 commit 129cd49

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

chain.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type Chain []*Link
3232
// Error returns the formatted error string
3333
func (c Chain) Error() string {
3434
lines := make([]string, 0, len(c))
35-
// source=<source> <prefix>: <error> tag=value tag2=value2 types=type1,type2
35+
//source=<source> <prefix>: <error> tag=value tag2=value2 types=type1,type2
3636
for i := len(c) - 1; i >= 0; i-- {
3737
line := c[i].formatError()
3838
lines = append(lines, line)
@@ -65,10 +65,15 @@ func (l *Link) formatError() string {
6565
line := fmt.Sprintf("source=%s ", l.Source)
6666

6767
if l.Prefix != "" {
68-
line += l.Prefix + ": "
68+
line += l.Prefix
6969
}
7070

71-
line += l.Err.Error()
71+
if _, ok := l.Err.(Chain); !ok {
72+
if l.Prefix != "" {
73+
line += ": "
74+
}
75+
line += l.Err.Error()
76+
}
7277

7378
for _, tag := range l.Tags {
7479
line += fmt.Sprintf(" %s=%v", tag.Key, tag.Value)

0 commit comments

Comments
 (0)