-
Notifications
You must be signed in to change notification settings - Fork 23
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
Conversation
There was a problem hiding this 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
catch_value = Object.new | ||
exc.instance_variable_set(:@catch_value, catch_value) | ||
::Kernel.catch(catch_value) {yield exc} |
There was a problem hiding this comment.
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?
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} |
There was a problem hiding this comment.
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]
Idea from nobu.
b28456d
to
25de5e4
Compare
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]