Rescuing multiple java exceptions or multiple java and ruby exceptions doesn't
catch them
-----------------------------------------------------------------------------------------
Key: JRUBY-6146
URL: https://jira.codehaus.org/browse/JRUBY-6146
Project: JRuby
Issue Type: Bug
Components: Core Classes/Modules
Affects Versions: JRuby 1.6.4
Environment: OS X 10.6.7
Reporter: Sam Gibson
When rescuing multiple exceptions, if a Java exception is not the first
exception in the rescue list is won't actually get rescued properly.
E.g.
require 'java'
java_import 'java.lang.NullPointerException'
java_import 'java.lang.IllegalArgumentException'
# This doesn't catch the java exception...
begin
raise IllegalArgumentException.new("This won't be caught.")
rescue IOError, IllegalArgumentException => e
puts "Saved!"
end
# This does catch the ruby exception...
begin
raise IOError.new("This will be caught.")
rescue IOError, IllegalArgumentException => e
puts "Saved!"
end
# This does catch the java exception...
begin
raise IllegalArgumentException.new("This will be caught.")
rescue IllegalArgumentException => e
puts "Saved!"
end
# When only ruby exceptions are used, it seems to work as expected...
begin
raise IOError, "keyboard not found, press f1 to continue"
rescue IndexError, IOError => e
puts "PEBKAC!"
end
# When only java exceptions are used, it still fails...
begin
raise IllegalArgumentException.new("The Spice Girls are the best band ever")
rescue NullPointerException, IllegalArgumentException => e
puts "Oh god, fix this bug so that that exception can't be true"
end
# When the raised exception is the first in the rescue list it works properly...
begin
raise NullPointerException.new("This will be caught.")
rescue NullPointerException, IllegalArgumentException => e
puts "Saved!"
end
--
This message is automatically generated by JIRA.
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