Skip to content

Commit 0d0f081

Browse files
committed
Fix traceback for wrapped Java exceptions
1 parent bfd6c0c commit 0d0f081

File tree

1 file changed

+8
-3
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/exception

1 file changed

+8
-3
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/exception/PException.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ public PException(PBaseException actual, Node node) {
9595
this.pythonException = actual;
9696
}
9797

98-
public PException(PBaseException actual, Node node, Throwable cause) {
99-
super(null, cause, UNLIMITED_STACK_TRACE, node);
98+
public PException(PBaseException actual, Node node, Throwable wrapped) {
99+
super(null, wrapped, UNLIMITED_STACK_TRACE, node);
100100
this.pythonException = actual;
101101
}
102102

@@ -231,7 +231,12 @@ public Iterable<TruffleStackTraceElement> getTruffleStackTrace() {
231231
if (tracebackCutoffTarget == null) {
232232
tracebackCutoffTarget = Truffle.getRuntime().getCurrentFrame().getCallTarget();
233233
}
234-
return TruffleStackTrace.getStackTrace(this);
234+
// Cause may contain wrapped Java exception
235+
if (getCause() != null) {
236+
return TruffleStackTrace.getStackTrace(getCause());
237+
} else {
238+
return TruffleStackTrace.getStackTrace(this);
239+
}
235240
}
236241

237242
public boolean shouldCutOffTraceback(TruffleStackTraceElement element) {

0 commit comments

Comments
 (0)