Re: [jruby-user] Convert Ruby Exceptions to Java
Karol Bucek <[email protected]>
| Newsgroups | gmane.comp.lang.jruby.user |
|---|---|
| Message-ID | <CAOcitDJ=Yyx3eGBiCjpXxO3h-HRG5qG350g1ix9grKnu-gQu_g@mail.gmail.com> |
you can still emulate ~ wrapping ... if you've looked at the linked
RaiseException.java there's a constructor that takes a RubyException :
begin
raise "error"
rescue => e
t = org.jruby.exceptions.RaiseException.new(e)
logger.error("This doesn't ... but will !", t)
end
although this might not be ideal, I would consider adding a "Ruby" logging
method (on each level) to the logger's class that would format errors with
their back-traces
K.
On Tue, Aug 5, 2014 at 5:20 AM, Ariel Valentin <[email protected]>
wrote:
> The code is still executing in the Ruby context. e.g.
> https://gist.github.com/arielvalentin/c340ae45dd83af8fd9d9
>
> Ariel Valentin
> e-mail: [email protected]
> website: http://blog.arielvalentin.com
> skype: ariel.s.valentin
> twitter: arielvalentin
> linkedin: http://www.linkedin.com/profile/view?id=8996534
> ---------------------------------------
> *simplicity *communication
> *feedback *courage *respect
>
>
> On Mon, Aug 4, 2014 at 4:24 PM, Theo Hultberg <[email protected]> wrote:
>
>> when Ruby exception bubble into Java they are wrapped in instances of
>> RaiseException, a subclass of RuntimeException. The constructor of
>> RaiseException takes a RubyException so they should do the job:
>>
>>
>> https://github.com/jruby/jruby/blob/master/core/src/main/java/org/jruby/exceptions/RaiseException.java
>>
>> T#
>>
>>
>> On Mon, Aug 4, 2014 at 3:40 PM, Ariel Valentin <[email protected]>
>> wrote:
>>
>>> Is anyone aware of a convenient way to convert Ruby exceptions into Java
>>> Throwable? I am trying to use an slf4j logger to log Ruby errors.
>>>
>>> Thanks,
>>> Ariel Valentin
>>> e-mail: [email protected]
>>> website: http://blog.arielvalentin.com
>>> skype: ariel.s.valentin
>>> twitter: arielvalentin
>>> linkedin: http://www.linkedin.com/profile/view?id=8996534
>>> ---------------------------------------
>>> *simplicity *communication
>>> *feedback *courage *respect
>>>
>>
>>
>