Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add be.AssignedAs and deprecate be.Panic #5

Merged
merged 1 commit into from
Dec 2, 2024
Merged

Conversation

rliebz
Copy link
Owner

@rliebz rliebz commented Dec 2, 2024

I don't think the current panic assertion is very good, because asserting that something panics is a lot less effective than asserting the value of a panic. So this refactor makes it so you have to orchestrate the panic recovery yourself, but also makes it easier to assert something of type any with a more specific assertion.

And generally I think be.AssignedAs is a smart assertion to have. It roughly resembles the shape of be.ErrorAs, so it shouldn't be very surprising.

I don't think the current panic assertion is very good, because
asserting _that_ something panics is a lot less effective than asserting
the _value_ of a panic. So this refactor makes it so you have to
orchestrate the panic recovery yourself, but also makes it easier to
assert something of type `any` with a more specific assertion.

And generally I think `be.AssignedAs` is a smart assertion to have. It
roughly resembles the shape of `be.ErrorAs`, so it shouldn't be very
surprising.
@rliebz rliebz merged commit 2090947 into main Dec 2, 2024
7 checks passed
@rliebz rliebz deleted the panic-assertions branch December 2, 2024 16:02
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.

1 participant