Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

chore: Change errors.HasType to respect multi-errors #63024

Merged
merged 8 commits into from
Jun 6, 2024

Conversation

varungandhi-src
Copy link
Contributor

With this patch, the errors.HasType API behaves similar to Is and As,
where it checks the full error tree instead of just checking a linearized version
of it, as cockroachdb/errors's HasType implementation does not respect
multi-errors (cockroachdb/errors#145).

As a consequence, a bunch of relationships between HasType and Is/As that
you'd intuitively expect to hold are now true; see changes to invariants_test.go.

Q: Why not make the change upstream and submit a version bump PR here?
A: This PR also tweaks the API to use a type argument rather than a value
argument, since the call-site is less clearer when you pass a value to check
the type. However, that would be a breaking change to make upstream,
so we just make that here.

Test plan

If we have tests for the existing error paths, then this should be good enough.

Changelog

@cla-bot cla-bot bot added the cla-signed label Jun 2, 2024
Copy link

graphite-app bot commented Jun 2, 2024

(Notifying @sourcegraph/source of a change that affects gitserver)

@graphite-app graphite-app bot added the team/source Tickets under the purview of Source - the one Source to graph it all label Jun 2, 2024
@github-actions github-actions bot added team/graph Graph Team (previously Code Intel/Language Tools/Language Platform) team/product-platform labels Jun 2, 2024
Base automatically changed from vg/err-invariants to main June 3, 2024 11:46
@varungandhi-src varungandhi-src enabled auto-merge (squash) June 3, 2024 11:50
@varungandhi-src
Copy link
Contributor Author

Sorry had to force-push to resolve merge conflicts

@varungandhi-src varungandhi-src merged commit 2955bb6 into main Jun 6, 2024
13 of 14 checks passed
@varungandhi-src varungandhi-src deleted the vg/replace-HasType branch June 6, 2024 13:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla-signed team/graph Graph Team (previously Code Intel/Language Tools/Language Platform) team/product-platform team/source Tickets under the purview of Source - the one Source to graph it all
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants