Hi all.
I'm using rspec to test an API which we support as Ruby but which is
written in Java. When a failure occurs, I get a backtrace like this:
A problem occurred (Java::Acme::LicenceException)
Java::Acme::LicenceException:
A problem occurred
com.acme.Widget.initialise(Widget.java:80)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(JavaMethod.java:440)
[... cutting the rest for brevity in email ...]
The real cause for the exception which I would like to read is in the
Java exception's cause... which normally would be on the stack trace,
but isn't. The suppressed exceptions might be useful too, of course...
I have tried adding -d to the JRuby command and --backtrace to the
rspec command, but neither of these appear to change the behaviour.
Is there any way to get this?
TX
P.S. Here's how I'm actually running it all, in case that matters:
<java fork="yes" classname="org.jruby.Main" failonerror="false">
<classpath refid="run-classpath" />
<env key="CI_REPORTS" value="@{reportdir}" />
<arg value="-d"/> <!-- seems to make no difference -->
<arg line="-S rspec"/>
<arg value="src/test/rspec"/> <!-- Path to root specs dir -->
<arg value="--backtrace"/> <!-- seems to make no difference -->
<arg line="--require ci/reporter/rake/rspec_loader"/>
<arg line="--format CI::Reporter::RSpecDoc"/>
<arg line="--format html --out"/> <arg
value="@{reportdir}/specs.html"/>
</java>
on 2013-01-25 04:26
on 2013-05-07 09:03
On Sun, Feb 3, 2013 at 10:05 AM, Roger Pack <lists@ruby-forum.com>
wrote:
> try jruby -h there may be some parameter...
Not as far as I can tell (the fact that I mentioned already using a
JRuby parameter to try and get this to happen may hint to some that I
had already looked through the docs.)
I was hoping that there would be a hidden switch somewhere to make
Java exceptions suck less when output by Ruby...
TX
on 2013-05-07 19:34
On May 7, 2013, at 3:01 AM, Trejkaz wrote: > On Sun, Feb 3, 2013 at 10:05 AM, Roger Pack <lists@ruby-forum.com> wrote: >> try jruby -h there may be some parameter... > > Not as far as I can tell (the fact that I mentioned already using a > JRuby parameter to try and get this to happen may hint to some that I > had already looked through the docs.) > > I was hoping that there would be a hidden switch somewhere to make > Java exceptions suck less when output by Ruby I created a log4jruby gem some time ago which we've been using successfully for quite some time. It handles exception unraveling. e.g. # this would log the error message and the full stack trace rescue => e logger.error(e) .. I'm not aware of anything built in. You can probably lift some code from log4jruby if not use it directly. https://github.com/lenny/log4jruby -lenny
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.