Ensure core exceptions get raised with $! as cause#9409
Conversation
1855854 to
9804bb8
Compare
|
@eregon There are some modifications to mspec's |
|
Failures appear to be GHA issues or bad timing in specs, unrelated to these changes. |
|
Thank you for adding more My initial thought here is whether making -> { 1 / 0 }.should raise_error(ZeroDivisionError, cause:)
# vs
-> { 1 / 0 }.should raise_error(ZeroDivisionError) { |e| e.cause.should == cause }It looks nice and it's expressive but OTOH it's not used in that many files. The main concern is MSpec tries to be as simple as possible so it can be used by early Ruby implementations. If you want to modify |
I think it will be used in many more as we continue to specify language-level exceptions that should have causes. I've only added a few cases here. And even without those additional cases, there were many places doing the block form of |
9804bb8 to
7ae3e91
Compare
|
@eregon I cleaned up the commit that adds the |
eregon
left a comment
There was a problem hiding this comment.
Thank you, looks good, just needs a few more tweaks and it's good to go
7ae3e91 to
a08313e
Compare
This adds a cause kwarg to raise_error for matching the cause of a captured exception. The error output for failed cases is also modified to show both message and cause if they are being matched.
a08313e to
45e6592
Compare
|
All requested changes have been made, merging. |
Many places where we raise exceptions from JRuby core code, we do not attach $! as a cause. This leads to several issues, including part of the issue reported in #9398. This PR adds specs and fixes known cases.