Raising Native Exceptions

View: New views
2 Messages — Rating Filter:   Alert me  

Raising Native Exceptions

by Fouad Mardini :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I am having an issue with raising java exceptions from ruby
Googling around I found this http://jira.codehaus.org/browse/JRUBY-1615 which 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 :)

--
Fouad Mardini

Re: Raising Native Exceptions

by Thomas E Enebo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 Mardini <f.mardini@...> wrote:

> Hello,
> I am having an issue with raising java exceptions from ruby
> Googling around I found this http://jira.codehaus.org/browse/JRUBY-1615
> which 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 :)
> --
> Fouad Mardini



--
blog: http://blog.enebo.com       twitter: tom_enebo
mail: tom.enebo@...

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email