Grant Gardner created JRUBY-6390:
------------------------------------
Summary: Compatibility of 1.9 rescue behaviour with MRI
Key: JRUBY-6390
URL: https://jira.codehaus.org/browse/JRUBY-6390
Project: JRuby
Issue Type: Improvement
Components: Core Classes/Modules, Ruby 1.9.2
Reporter: Grant Gardner
Priority: Minor
MRI Ruby 1.9 seems to have inadvertently dropped the requirement that args to
rescue must be a class or module
See http://bugs.ruby-lang.org/issues/4438
The result however turns out to be quite useful
http://ablogaboutcode.com/2011/09/21/dynamic-rescue-clause-in-ruby/
http://carboni.ca/blog/p/Ruby-Did-You-Know-That-2-Exception-Handling
{code}
a = Object.new()
def a.===(val)
val.message =~ /fancy/
end
begin
raise "a fancy runtime exception"
rescue a
puts "Rescued my fancy exception without being a class or module"
end
{code}
In MRI 1.9.2+ the rescue clause is successful.
in JRuby 1.6.5.1 with --1.9 we get
{quote}
TypeError: class or module required for rescue clause
{quote}
which is equivalent to the MRI 1.8.7 output
{quote}
class or module required for rescue clause (TypeError)
{quote}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email