Skip to content

Commit

Permalink
implement interface { Unwrap() []error } for AggregateError to be com…
Browse files Browse the repository at this point in the history
…patibility with std errors.Join go1.20 without any breaking change
  • Loading branch information
itsabgr committed Oct 7, 2024
1 parent 84c7739 commit 08df6e3
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 08df6e3

Please sign in to comment.