Skip to content

Commit

Permalink
barriers: clarify the verbose formatting
Browse files Browse the repository at this point in the history
Before:

```
some error
- original cause behind barrier:
  original message
  - original details
```

After:

```
some error
- original cause behind barrier: original message
  - original details
```

Suggested by @RaduBerinde.
  • Loading branch information
knz committed Jul 9, 2019
1 parent 9d0253e commit 033ea20
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 23 deletions.
2 changes: 1 addition & 1 deletion barriers/barriers.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (e *barrierError) Format(s fmt.State, verb rune) { errbase.FormatError(e, s
func (e *barrierError) FormatError(p errbase.Printer) (next error) {
p.Print(e.msg)
if p.Detail() {
p.Printf("\noriginal cause behind barrier:\n%+v", e.maskedErr)
p.Printf("\noriginal cause behind barrier: %+v", e.maskedErr)
}
return nil
}
Expand Down
21 changes: 7 additions & 14 deletions barriers/barriers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,34 +113,27 @@ func TestFormat(t *testing.T) {
}{
{"handled", barriers.Handled(goErr.New("woo")), woo, `
woo:
original cause behind barrier:
woo`},
original cause behind barrier: woo`},

{"handled + handled", barriers.Handled(barriers.Handled(goErr.New("woo"))), woo, `
woo:
original cause behind barrier:
woo:
original cause behind barrier:
woo`},
original cause behind barrier: woo:
original cause behind barrier: woo`},

{"handledmsg", barriers.HandledWithMessage(goErr.New("woo"), "waa"), "waa", `
waa:
original cause behind barrier:
woo`},
original cause behind barrier: woo`},

{"handledmsg + handledmsg", barriers.HandledWithMessage(
barriers.HandledWithMessage(
goErr.New("woo"), "waa"), "wuu"), `wuu`, `
wuu:
original cause behind barrier:
waa:
original cause behind barrier:
woo`},
original cause behind barrier: waa:
original cause behind barrier: woo`},

{"handled + wrapper", barriers.Handled(&werrFmt{goErr.New("woo"), "waa"}), waawoo, `
waa: woo:
original cause behind barrier:
waa:
original cause behind barrier: waa:
-- verbose wrapper:
waa
- woo`},
Expand Down
12 changes: 4 additions & 8 deletions errutil/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ assertion failure
runtime.goexit
<tab><path>
- wuu: woo:
original cause behind barrier:
wuu:
original cause behind barrier: wuu:
-- verbose wrapper:
wuu
- woo`,
Expand All @@ -157,8 +156,7 @@ assertion failure
-- arg 1: <string>
- waa: hello:
- wuu: woo:
original cause behind barrier:
wuu:
original cause behind barrier: wuu:
-- verbose wrapper:
wuu
- woo`,
Expand All @@ -176,8 +174,7 @@ assertion failure
runtime.goexit
<tab><path>
- wuu: woo:
original cause behind barrier:
wuu:
original cause behind barrier: wuu:
-- verbose wrapper:
wuu
- woo`,
Expand All @@ -198,8 +195,7 @@ assertion failure
-- arg 1: <int>
- %!(EXTRA int=123):
- wuu: woo:
original cause behind barrier:
wuu:
original cause behind barrier: wuu:
-- verbose wrapper:
wuu
- woo`,
Expand Down

0 comments on commit 033ea20

Please sign in to comment.