Merge 173e9ba38f
into b7c059886c
This commit is contained in:
commit
f36cde3db2
2 changed files with 4 additions and 5 deletions
|
@ -31,9 +31,6 @@ type joinError struct {
|
|||
}
|
||||
|
||||
func (e *joinError) Error() string {
|
||||
if len(e.errs) == 1 {
|
||||
return strings.TrimSpace(e.errs[0].Error())
|
||||
}
|
||||
stringErrs := make([]string, 0, len(e.errs))
|
||||
for _, subErr := range e.errs {
|
||||
stringErrs = append(stringErrs, strings.Replace(subErr.Error(), "\n", "\n\t", -1))
|
||||
|
|
|
@ -10,10 +10,12 @@ import (
|
|||
|
||||
func TestErrorJoin(t *testing.T) {
|
||||
t.Run("single", func(t *testing.T) {
|
||||
err := Join(fmt.Errorf("invalid config: %w", Join(errors.New("foo"))))
|
||||
const expected = `invalid config: foo`
|
||||
err := fmt.Errorf("invalid config:\n%w", Join(errors.New("foo")))
|
||||
const expected = `invalid config:
|
||||
* foo`
|
||||
assert.Equal(t, err.Error(), expected)
|
||||
})
|
||||
|
||||
t.Run("multiple", func(t *testing.T) {
|
||||
err := Join(errors.New("foobar"), fmt.Errorf("invalid config: \n%w", Join(errors.New("foo"), errors.New("bar"))))
|
||||
const expected = `* foobar
|
||||
|
|
Loading…
Add table
Reference in a new issue