Skip to content

Commit 77d194f

Browse files
committed
Print Java stacktrace of cause for wrapped Java exceptions.
1 parent da7064f commit 77d194f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/control/TopLevelExceptionHandler.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,12 @@ private static void printJavaStackTrace(PException e) {
264264
traceback = traceback.getNextChain();
265265
}
266266
if (traceback != null) {
267-
traceback.getException().printStackTrace();
267+
PException exception = traceback.getException();
268+
if (exception.getCause() != null && exception.getCause().getStackTrace().length != 0) {
269+
exception.getCause().printStackTrace();
270+
} else {
271+
exception.printStackTrace();
272+
}
268273
}
269274
}
270275

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/statement/ExceptionHandlingStatementNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ protected final PException wrapJavaExceptionIfApplicable(Throwable e) {
218218

219219
@TruffleBoundary
220220
private static void moveTruffleStackTrace(Throwable e, PException pe) {
221-
pe.initCause(e.getCause());
221+
pe.initCause(e);
222222
// Host exceptions have their stacktrace already filled in, call this to set
223223
// the cutoff point to the catch site
224224
pe.getTruffleStackTrace();

0 commit comments

Comments
 (0)