Skip to content

Commit

Permalink
fix IS & As going directly to error
Browse files Browse the repository at this point in the history
  • Loading branch information
deankarn committed Aug 17, 2023
1 parent 2a8ec39 commit 70ce3fe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func (c Chain) Is(target error) bool {
}
target = innerErr[0].Err
}
return stderrors.Is(c[len(c)-1].Err, target)
return stderrors.Is(c[0].Err, target)
}

// As finds the first error in the error chain that matches target, and if so, sets
Expand All @@ -245,7 +245,7 @@ func (c Chain) As(target any) bool {
if len(c) == 0 {
return false
}
return stderrors.As(c[len(c)-1].Err, target)
return stderrors.As(c[0].Err, target)
}

func defaultFormatFn(c Chain) string {
Expand Down

0 comments on commit 70ce3fe

Please sign in to comment.