Skip to content

Commit 5e478a1

Browse files
committed
Use suggested unwrapAll
1 parent 95dafb4 commit 5e478a1

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

assert/assertions.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2171,23 +2171,22 @@ func NotErrorAs(t TestingT, err error, target interface{}, msgAndArgs ...interfa
21712171

21722172
func unwrapAll(err error) (errs []error) {
21732173
errs = append(errs, err)
2174-
for {
2175-
switch x := err.(type) {
2176-
case interface{ Unwrap() error }:
2177-
err = x.Unwrap()
2178-
if err == nil {
2179-
return
2180-
}
2181-
errs = append(errs, err)
2182-
case interface{ Unwrap() []error }:
2183-
for _, err := range x.Unwrap() {
2184-
errs = append(errs, unwrapAll(err)...)
2185-
}
2186-
return
2187-
default:
2174+
switch x := err.(type) {
2175+
case interface{ Unwrap() error }:
2176+
err = x.Unwrap()
2177+
if err == nil {
21882178
return
21892179
}
2180+
errs = append(errs, unwrapAll(err)...)
2181+
case interface{ Unwrap() []error }:
2182+
for _, err := range x.Unwrap() {
2183+
errs = append(errs, unwrapAll(err)...)
2184+
}
2185+
return
2186+
default:
2187+
return
21902188
}
2189+
return
21912190
}
21922191

21932192
func buildErrorChainString(err error, withType bool) string {

0 commit comments

Comments
 (0)