Skip to content

Commit

Permalink
[Truffle] Print Ruby backtraces when an exception occurs in an at_exi…
Browse files Browse the repository at this point in the history
…t block.
  • Loading branch information
nirvdrum committed Feb 20, 2015
1 parent 169a9e3 commit d45b55c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion truffle/src/main/java/org/jruby/truffle/TruffleBridgeImpl.java
Expand Up @@ -23,8 +23,11 @@
import org.jruby.truffle.nodes.core.*;
import org.jruby.truffle.nodes.rubinius.ByteArrayNodesFactory;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.backtrace.Backtrace;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.RubyArray;
import org.jruby.truffle.runtime.core.RubyClass;
import org.jruby.truffle.runtime.core.RubyException;
import org.jruby.truffle.runtime.util.FileUtils;
import org.jruby.truffle.translator.NodeWrapper;
import org.jruby.truffle.translator.TranslatorDriver;
Expand Down Expand Up @@ -188,7 +191,15 @@ public Object toTruffle(IRubyObject object) {

@Override
public void shutdown() {
truffleContext.shutdown();
try {
truffleContext.shutdown();
} catch (RaiseException e) {
final RubyException rubyException = e.getRubyException();

for (String line : Backtrace.DISPLAY_FORMATTER.format(e.getRubyException().getContext(), rubyException, rubyException.getBacktrace())) {
System.err.println(line);
}
}
}

}

0 comments on commit d45b55c

Please sign in to comment.