Skip to content

Commit 69e4761

Browse files
cfergeauonsi
authored andcommitted
fix(async_assertion): use correct error in errors.As
In AsyncAssertion.match, there is a confusion between actualErr/matcherErr in one of the branches: Before this commit, the code is: ``` if actualErr == nil if matcherErr == nil { // actualErr is nil, matcherErr is nil … } else { // actualErr is nil, matcherErr is non-nil var fgErr formattedGomegaError if errors.As(actualErr, &fgErr) { message += fgErr.FormattedGomegaError() + "\n" } else { message += renderError(fmt.Sprintf("The matcher passed to %s returned the following error:", assertion.asyncType), matcherErr) } } } else { // actualErr is non-nil … } ``` Calling `errors.As` on the nil `actualErr` looks like a mistake, this commit changes it to `matcherErr` which is non-nil. This also matches the error used in the second branch of the `if errors.As()` test. This was reported by a static analysis tool. Signed-off-by: Christophe Fergeau <[email protected]>
1 parent 95737c0 commit 69e4761

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

internal/async_assertion.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch
452452
}
453453
} else {
454454
var fgErr formattedGomegaError
455-
if errors.As(actualErr, &fgErr) {
455+
if errors.As(matcherErr, &fgErr) {
456456
message += fgErr.FormattedGomegaError() + "\n"
457457
} else {
458458
message += renderError(fmt.Sprintf("The matcher passed to %s returned the following error:", assertion.asyncType), matcherErr)

0 commit comments

Comments
 (0)