@@ -732,6 +732,9 @@ public class PApplet implements PConstants {
732732 /** true if the sketch has stopped permanently. */
733733 public volatile boolean finished ;
734734
735+ /** used by the UncaughtExceptionHandler, so has to be static */
736+ static Throwable uncaughtThrowable ;
737+
735738 // public, but undocumented.. removing for 3.0a5
736739// /**
737740// * true if the animation thread is paused.
@@ -5297,7 +5300,7 @@ public PImage loadImage(String filename, String extension) { //, Object params)
52975300// }
52985301 return image ;
52995302 } catch (IOException e ) {
5300- e . printStackTrace ();
5303+ printStackTrace (e );
53015304 return null ;
53025305 }
53035306 }
@@ -5367,7 +5370,7 @@ public PImage loadImage(String filename, String extension) { //, Object params)
53675370 }
53685371 } catch (Exception e ) {
53695372 // show error, but move on to the stuff below, see if it'll work
5370- e . printStackTrace ();
5373+ printStackTrace (e );
53715374 }
53725375
53735376 if (loadImageFormats == null ) {
@@ -5557,7 +5560,7 @@ protected PImage loadImageIO(String filename) {
55575560 return outgoing ;
55585561
55595562 } catch (Exception e ) {
5560- e . printStackTrace ();
5563+ printStackTrace (e );
55615564 return null ;
55625565 }
55635566 }
@@ -6029,7 +6032,7 @@ public Table loadTable(String filename, String options) {
60296032 return new Table (input , optionStr );
60306033
60316034 } catch (IOException e ) {
6032- e . printStackTrace ();
6035+ printStackTrace (e );
60336036 return null ;
60346037 }
60356038 }
@@ -6069,7 +6072,7 @@ public boolean saveTable(Table table, String filename, String options) {
60696072 return table .save (outputFile , options );
60706073
60716074 } catch (IOException e ) {
6072- e . printStackTrace ();
6075+ printStackTrace (e );
60736076 return false ;
60746077 }
60756078 }
@@ -6739,7 +6742,7 @@ public InputStream createInput(String filename) {
67396742 try {
67406743 return new GZIPInputStream (input );
67416744 } catch (IOException e ) {
6742- e . printStackTrace ();
6745+ printStackTrace (e );
67436746 return null ;
67446747 }
67456748 }
@@ -6794,7 +6797,7 @@ public InputStream createInputRaw(String filename) {
67946797
67956798 } catch (IOException e ) {
67966799 // changed for 0117, shouldn't be throwing exception
6797- e . printStackTrace ();
6800+ printStackTrace (e );
67986801 //System.err.println("Error downloading from URL " + filename);
67996802 return null ;
68006803 //throw new RuntimeException("Error downloading from URL " + filename);
@@ -6900,8 +6903,7 @@ public InputStream createInputRaw(String filename) {
69006903 } catch (SecurityException se ) { } // online, whups
69016904
69026905 } catch (Exception e ) {
6903- //die(e.getMessage(), e);
6904- e .printStackTrace ();
6906+ printStackTrace (e );
69056907 }
69066908
69076909 return null ;
@@ -6957,7 +6959,7 @@ public byte[] loadBytes(String filename) {
69576959 try {
69586960 is .close ();
69596961 } catch (IOException e ) {
6960- e . printStackTrace (); // shouldn't happen
6962+ printStackTrace (e ); // shouldn't happen
69616963 }
69626964 return outgoing ;
69636965 }
@@ -7073,7 +7075,7 @@ public String[] loadStrings(String filename) {
70737075 try {
70747076 is .close ();
70757077 } catch (IOException e ) {
7076- e . printStackTrace ();
7078+ printStackTrace (e );
70777079 }
70787080 return strArr ;
70797081 }
@@ -10114,6 +10116,13 @@ static public void runSketch(final String[] args,
1011410116 // Remove 60fps limit on the JavaFX "pulse" timer
1011510117 System .setProperty ("javafx.animation.fullspeed" , "true" );
1011610118
10119+ Thread .setDefaultUncaughtExceptionHandler (new Thread .UncaughtExceptionHandler () {
10120+ public void uncaughtException (Thread t , Throwable e ) {
10121+ e .printStackTrace ();
10122+ uncaughtThrowable = e ;
10123+ }
10124+ });
10125+
1011710126 // This doesn't work, need to mess with Info.plist instead
1011810127 /*
1011910128 // In an exported application, add the Contents/Java folder to the
0 commit comments