Skip to content

Commit bd853ad

Browse files
committed
Merge pull request processing#4152 from gohai/recursion-message
Make the error message for stack overflows clearer
2 parents e75a7b3 + 00c874d commit bd853ad

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

java/src/processing/mode/java/runner/Runner.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,12 @@ protected SketchException findException(String message, ObjectReference or, Thre
749749
// This shouldn't happen, but if it does, print the exception in case
750750
// it's something that needs to be debugged separately.
751751
e.printStackTrace(sketchErr);
752+
} catch (Exception e) {
753+
// stack overflows seem to trip in frame.location() above
754+
// ignore this case so that the actual error gets reported to the user
755+
if ("StackOverflowError".equals(message) == false) {
756+
e.printStackTrace(sketchErr);
757+
}
752758
}
753759
// before giving up, try to extract from the throwable object itself
754760
// since sometimes exceptions are re-thrown from a different context
@@ -780,7 +786,11 @@ protected SketchException findException(String message, ObjectReference or, Thre
780786
or.invokeMethod(thread, method, new ArrayList<Value>(), ObjectReference.INVOKE_SINGLE_THREADED);
781787

782788
} catch (Exception e) {
783-
e.printStackTrace(sketchErr);
789+
// stack overflows will make the exception handling above trip again
790+
// ignore this case so that the actual error gets reported to the user
791+
if ("StackOverflowError".equals(message) == false) {
792+
e.printStackTrace(sketchErr);
793+
}
784794
}
785795
// Give up, nothing found inside the pile of stack frames
786796
SketchException rex = new SketchException(message);

0 commit comments

Comments
 (0)