GODRIVER-2721 Fully support "errors.Is" and "errors.As". #1969
+30
−23
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
GODRIVER-2721
Summary
This PR draft is not meant to be merged.This PR and #1984 replace error assertions (except those in
replaceErrors()
in "mongo\errors.go") witherrors.Is()
anderrors.As()
.However, the error assertion checks the immediate error type. Instead,
errors.Is()
/errors.As()
trace the error tree.The difference changes the current error handling logic so they are not proper. Moreover, any further replacements inThe difference changes the error handling logic so any further replacements inreplaceErrors()
will cause regression failures because of the logic change.replaceErrors()
will cause regression failures.replaceErrors()
will be replaced in another PR.In conclusion, we should not replace error assertions witherrors.Is()
/errors.As()
in the current code base.We can consider closing GODRIVER-2721 and GODRIVER-2975, or making GODRIVER-2721 an epic for tickets such as GODRIVER-1854 and GODRIVER-2704.Background & Motivation