Skip to content

Commit

Permalink
use new iterator API instead of deprecated API
Browse files Browse the repository at this point in the history
  • Loading branch information
gregwebs committed Jan 22, 2025
1 parent 521f1d4 commit 04c2232
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions group.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,16 @@ import (

// ErrorCodes return all errors (including those grouped) that are of interface ErrorCode.
// It first calls the Errors function.
func ErrorCodes(err error) []ErrorCode {
func ErrorCodes(errIn error) []ErrorCode {
errorCodes := make([]ErrorCode, 0)
//nolint:staticcheck
errwrap.WalkDeep(err, func(err error) bool {
for err := range errwrap.UnwrapGroups(errIn) {
if errcode, ok := err.(ErrorCode); ok {
// avoid duplicating codes
if len(errorCodes) == 0 || errorCodes[len(errorCodes)-1].Code().codeStr != errcode.Code().codeStr {
errorCodes = append(errorCodes, errcode)
}
}
return false
})
}
return errorCodes
}

Expand Down

0 comments on commit 04c2232

Please sign in to comment.