Permalink
Browse files

Fix JRUBY-6642.

RubyException.printBacktrace will now print all lines by default,
and has a separate form for skipping some number of lines. All
internal uses that expected the first line to be skipped use the
second form.
  • Loading branch information...
1 parent 82a2f2d commit 9a122edb309d8b86d76d05f65a1779ae17259755 @headius headius committed with May 14, 2012
@@ -293,11 +293,15 @@ public void copySpecialInstanceVariables(IRubyObject clone) {
}
public void printBacktrace(PrintStream errorStream) {
+ printBacktrace(errorStream, 0);
+ }
+
+ public void printBacktrace(PrintStream errorStream, int skip) {
IRubyObject backtrace = callMethod(getRuntime().getCurrentContext(), "backtrace");
if (!backtrace.isNil() && backtrace instanceof RubyArray) {
IRubyObject[] elements = backtrace.convertToArray().toJavaArray();
- for (int i = 1; i < elements.length; i++) {
+ for (int i = skip; i < elements.length; i++) {
IRubyObject stackTraceLine = elements[i];
if (stackTraceLine instanceof RubyString) {
printStackTraceLine(errorStream, stackTraceLine);
@@ -85,7 +85,7 @@ public RaiseException(RubyException actException) {
* @param backtrace
*/
public RaiseException(RubyException exception, IRubyObject backtrace) {
- super();
+ super(exception.message.toString());
if (DEBUG) {
Thread.dumpStack();
}
@@ -132,7 +132,7 @@ public RaiseException(Ruby runtime, RubyClass excptnClass, String msg, IRubyObje
}
public RaiseException(RubyException exception, boolean isNativeException) {
- super();
+ super(exception.message.toString());
if (DEBUG) {
Thread.dumpStack();
}
@@ -208,7 +208,7 @@ protected static String printBacktraceMRI(RubyException exception) {
}
}
- exception.printBacktrace(errorStream);
+ exception.printBacktrace(errorStream, 1);
return new String(baos.toByteArray());
}
@@ -69,7 +69,7 @@ public void testPrintNilBacktrace() throws Exception {
private String[] printError() {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(2048);
PrintStream stream = new PrintStream(byteArrayOutputStream);
- exception.printBacktrace(stream);
+ exception.printBacktrace(stream, 1);
String output = new String(byteArrayOutputStream.toByteArray());
if (output.trim().length() == 0) {
return new String[0];

0 comments on commit 9a122ed

Please sign in to comment.