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

Make Timeout::Error#exception with multiple arguments not ignore arguments #3

Merged
merged 3 commits into from
May 3, 2021

Conversation

jeremyevans
Copy link
Contributor

This makes:

raise(Timeout::Error.new("hello"), "world")

raise a TimeoutError instance with "world" as the message instead
of "hello", for consistency with other Ruby exception classes.

This required some internal changes to keep the tests passing.

Fixes [Bug #17812]

@ioquatix ioquatix self-requested a review April 29, 2021 23:34
Copy link
Member

@ioquatix ioquatix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems okay to me. However it also seems like this was created before #cause was introduced. I am okay with the change, but I also wonder if rewriting an exceptions backtrace and message is really a good idea.

lib/timeout.rb Outdated
Comment on lines 35 to 37
catch_value = Object.new
exc.instance_variable_set(:@catch_value, catch_value)
::Kernel.catch(catch_value) {yield exc}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the different object needed?

Suggested change
catch_value = Object.new
exc.instance_variable_set(:@catch_value, catch_value)
::Kernel.catch(catch_value) {yield exc}
exc.instance_variable_set(:@catch_value, exc)
::Kernel.catch(exc) {yield exc}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try that approach, it would be good to avoid the object allocation.

…ments

This makes:

  raise(Timeout::Error.new("hello"), "world")

raise a TimeoutError instance with "world" as the message instead
of "hello", for consistency with other Ruby exception classes.

This required some internal changes to keep the tests passing.

Fixes [Bug #17812]
@jeremyevans jeremyevans force-pushed the exception-message-17812 branch from b28456d to 25de5e4 Compare May 3, 2021 15:40
@jeremyevans
Copy link
Contributor Author

@ioquatix CI was apparently having issues, with errors like: [TypeError] exception expected, not #<NoMethodError: undefined method current_scheduler for Fiber:Class>. I'm fixed it like this: 25de5e4. If that isn't correct, please push a commit to fix it.

@jeremyevans jeremyevans merged commit 4893cde into ruby:master May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants