Skip to content

Commit 0d117ee

Browse files
committed
add printStackTrace() method that can be overridden (fixes #222)
1 parent 345947a commit 0d117ee

2 files changed

Lines changed: 39 additions & 13 deletions

File tree

core/src/processing/core/PApplet.java

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ void handleSettings() {
979979
stderr.append(line);
980980
}
981981
} catch (IOException e) {
982-
e.printStackTrace();
982+
printStackTrace(e);
983983
}
984984

985985
int resultCode = -1;
@@ -1412,7 +1412,7 @@ void handle(Object[] args) {
14121412
throw (RuntimeException) t;
14131413
} else {
14141414
// trap and print as usual
1415-
t.printStackTrace();
1415+
printStackTrace(t);
14161416
}
14171417
}
14181418
}
@@ -2240,11 +2240,14 @@ protected PGraphics makeGraphics(int w, int h,
22402240
"specified with -Djava.library.path=/path/to/jogl");
22412241

22422242
} else {
2243-
ite.getTargetException().printStackTrace();
2243+
printStackTrace(ite.getTargetException());
22442244
Throwable target = ite.getTargetException();
2245+
/*
2246+
// removing for 3.2, we'll see
22452247
if (platform == MACOSX) {
22462248
target.printStackTrace(System.out); // OS X bug (still true?)
22472249
}
2250+
*/
22482251
throw new RuntimeException(target.getMessage());
22492252
}
22502253

@@ -2271,16 +2274,18 @@ protected PGraphics makeGraphics(int w, int h,
22712274
throw new RuntimeException(e);
22722275

22732276
} else {
2274-
e.printStackTrace();
2277+
printStackTrace(e);
22752278
String msg = renderer + " needs to be updated " +
22762279
"for the current release of Processing.";
22772280
throw new RuntimeException(msg);
22782281
}
22792282
} else {
2283+
/*
22802284
if (platform == MACOSX) {
22812285
e.printStackTrace(System.out); // OS X bug (still true?)
22822286
}
2283-
e.printStackTrace();
2287+
*/
2288+
printStackTrace(e);
22842289
throw new RuntimeException(e.getMessage());
22852290
}
22862291
}
@@ -3368,9 +3373,9 @@ public void link(String url) {
33683373
launch(url);
33693374
}
33703375
} catch (IOException e) {
3371-
e.printStackTrace();
3376+
printStackTrace(e);
33723377
} catch (URISyntaxException e) {
3373-
e.printStackTrace();
3378+
printStackTrace(e);
33743379
}
33753380
}
33763381

@@ -3472,8 +3477,7 @@ static public Process exec(String... args) {
34723477
try {
34733478
return Runtime.getRuntime().exec(args);
34743479
} catch (Exception e) {
3475-
e.printStackTrace();
3476-
throw new RuntimeException("Could not open " + join(args, ' '));
3480+
throw new RuntimeException("Could not open " + join(args, ' '), e);
34773481
}
34783482
}
34793483

@@ -3488,6 +3492,15 @@ static public Process exec(String... args) {
34883492
//////////////////////////////////////////////////////////////
34893493

34903494

3495+
/**
3496+
* Better way of handling e.printStackTrace() calls so that they can be
3497+
* handled by subclasses as necessary.
3498+
*/
3499+
protected void printStackTrace(Throwable t) {
3500+
t.printStackTrace();
3501+
}
3502+
3503+
34913504
/**
34923505
* Function for an applet/application to kill itself and
34933506
* display an error. Mostly this is here to be improved later.

todo.txt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ X rewrite Util.listFiles() because it wasn't working properly
1818
X add 2016 to about-1x and about-2x
1919
o saying "no" to save changes is the same as "cancel" on windows?
2020
X can't reproduce
21+
X add printStackTrace() method that can be overridden
22+
X https://github.com/processing/processing/issues/222
23+
_ update launch4j to 3.9
24+
_ https://sourceforge.net/projects/launch4j/files/launch4j-3/3.9/
2125

2226
mode work
2327
X add template support for Modes
@@ -38,9 +42,20 @@ _ write short docs
3842
_ https://github.com/processing/processing/issues/4306
3943
_ https://github.com/processing/processing/issues/4352
4044

45+
earlier
46+
X display "1" is not correct in 2.1.2
47+
X https://github.com/processing/processing/issues/2502
48+
49+
50+
_ editor windows always open on display 1
51+
_ https://github.com/processing/processing/issues/1566
52+
4153
_ allow modes to specify their own base file name
4254
_ need to move "is this a sketch?" handling into Mode
4355

56+
_ blank window on startup where the "welcome" screen should be
57+
_ https://github.com/processing/processing/issues/3933
58+
4459
_ modify line number color when no lines extend that far?
4560
_ https://github.com/processing/processing/pull/4560
4661
_ text gutter doesn't seem to be hidpi
@@ -87,10 +102,10 @@ _ https://github.com/processing/processing/issues/3965
87102
medium
88103
_ detect changes in case with libraries
89104
_ https://github.com/processing/processing/issues/4507
90-
91-
lower
92105
_ make when opening new editor window, open on the same display as current
93106
_ https://github.com/processing/processing/issues/4526
107+
_ hidpi scaling via font changes?
108+
_ http://stackoverflow.com/a/34152675
94109
_ hi-dpi support on Linux
95110
_ https://github.com/processing/processing/issues/4183
96111
_ PDE and sketches are 2x smaller on high-res Windows machines
@@ -288,8 +303,6 @@ _ when run from Eclipse, the single instance thing punts
288303
_ 'recent' menu needs to recognize the p5 app folder
289304
_ also should recognize the user's home dir
290305
_ possibility of libraries folder inside a particular sketch?
291-
_ display "1" is not correct in 2.1.2
292-
_ https://github.com/processing/processing/issues/2502
293306
_ add font fixes to the rest of the API
294307
_ https://github.com/processing/processing/commit/eaff673d173b2d27f276cf5c59e3abf6c0fab86b
295308
_ g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,

0 commit comments

Comments
 (0)