Skip to content

Replace errors.As with errors.AsType#8779

Open
ezekiel wants to merge 6 commits into
mainfrom
ezekiel/errors-as-type
Open

Replace errors.As with errors.AsType#8779
ezekiel wants to merge 6 commits into
mainfrom
ezekiel/errors-as-type

Conversation

@ezekiel
Copy link
Copy Markdown
Member

@ezekiel ezekiel commented Jun 4, 2026

This PR replaces all uses of errors.As() with errors.AsType[]().

One testing assertion, AssertErrorWraps, was updating the error supplied to the errors.As call with the unwrapped error result. Changing to errors.AsType, I have NOT preserved that behavior, which seemed spooky-at-a-distance. AssertErrorWraps was regularly followed-up with additional testing assertions on the presumably-unwrapped error, which cases just now have an additional errors.AsType call in their immediate vicinity to provide the unwrapped error.

Fixes #8541

ezekiel added 4 commits June 4, 2026 18:38
AssertErrorWraps NO LONGER has the side effect of unrapping the error,
so added errors.AsType calls to tests where that effect was being
relied-upon.
@ezekiel ezekiel changed the title Replace errors.As with errors.AsType everywhere Replace errors.As with errors.AsType Jun 5, 2026
@ezekiel ezekiel marked this pull request as ready for review June 5, 2026 14:57
@ezekiel ezekiel requested a review from a team as a code owner June 5, 2026 14:57
@ezekiel ezekiel requested a review from jsha June 5, 2026 14:57
Comment thread test/asserts.go Outdated
jsha
jsha previously approved these changes Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

go1.26: replace errors.As with errors.AsType

2 participants