Skip to content

Commit 5ef7edd

Browse files
committed
throw_java_exception_with_cause: explicitly fill in TruffleStackTrace in cause.
1 parent af0f15a commit 5ef7edd

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/main/java/org/truffleruby/debug/TruffleDebugNodes.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.util.List;
1919
import java.util.Map;
2020

21+
import com.oracle.truffle.api.TruffleStackTrace;
2122
import com.oracle.truffle.api.TruffleStackTraceElement;
2223
import com.oracle.truffle.api.exception.AbstractTruffleException;
2324
import com.oracle.truffle.api.frame.Frame;
@@ -489,9 +490,11 @@ public abstract static class ThrowJavaExceptionWithCauseNode extends CoreMethodA
489490
@Specialization(guards = "strings.isRubyString(message)", limit = "1")
490491
protected Object throwJavaExceptionWithCause(Object message,
491492
@Cached RubyStringLibrary strings) {
492-
throw new RuntimeException(
493-
RubyGuards.getJavaString(message),
494-
new RuntimeException("cause 1", new RuntimeException("cause 2")));
493+
var cause2 = new RuntimeException("cause 2");
494+
var cause1 = new RuntimeException("cause 1", cause2);
495+
TruffleStackTrace.fillIn(cause2);
496+
TruffleStackTrace.fillIn(cause1);
497+
throw new RuntimeException(RubyGuards.getJavaString(message), cause1);
495498
}
496499

497500
}

0 commit comments

Comments
 (0)