Skip to content

Commit

Permalink
feat: implement interface { Unwrap() []error } for AggregateError to …
Browse files Browse the repository at this point in the history
…be compatibility with std errors.Join go1.20 without any breaking change (#336)

Co-authored-by: abgr <[email protected]>
  • Loading branch information
itsabgr-raika and itsabgr authored Oct 8, 2024
1 parent 84c7739 commit 59284e4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ func (e AggregateError) Error() string {
return strings.TrimRight(sb.String(), ";")
}

// Unwrap implements std errors.Join go1.20 compatibility
func (e AggregateError) Unwrap() []error {
return e.Errors
}

// Is conforms with errors.Is.
func (e AggregateError) Is(err error) bool {
for _, ie := range e.Errors {
Expand Down

0 comments on commit 59284e4

Please sign in to comment.