Raising Native Exceptions

Hello,

I am having an issue with raising java exceptions from ruby
Googling around I found this
http://jira.codehaus.org/browse/JRUBY-1615which would suggest the
issue was solved
I am running jruby right out of git (branch jruby-1_4)

Boils down to this:

require ‘java’

begin
raise java.lang.Exception.new(“Hello”)

raise Exception.new(“Hello”)

rescue Object => e
puts e.to_s
end

Thanks for any pointers :slight_smile:

Can you file a bug on your example snippet? I think it is a bug, but
OTOH is an instance of a Java Object rooted at Ruby Object? I would
say it has to be a bug since all objects in Ruby space whether
imported from Java or not must be rooted by Ruby Object (or
BasicObject) in 1.9.

Here is a snippet which may capture what you are trying to do a little
more and it also works:

require ‘java’

begin
raise java.lang.Exception.new(“Hello”)

raise Exception.new(“Hello”)

rescue java.lang.Object => e
puts e.to_s
end

-Tom

On Sat, Nov 7, 2009 at 5:43 AM, Fouad M. [email protected]
wrote:

raise Exception.new(“Hello”)

rescue Object => e
puts e.to_s
end

Thanks for any pointers :slight_smile:

Fouad M.


blog: http://blog.enebo.com twitter: tom_enebo
mail: [email protected]


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email