Skip to content

Commit 634b7b5

Browse files
committed
will write to stderr as we dont see this message in stdout
1 parent 6f3ef56 commit 634b7b5

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package codeine;
22

3-
import java.lang.Thread.UncaughtExceptionHandler;
4-
53
import org.apache.log4j.BasicConfigurator;
64
import org.apache.log4j.Logger;
75

6+
import java.lang.Thread.UncaughtExceptionHandler;
7+
88
public class CodeineUncaughtExceptionHandler implements UncaughtExceptionHandler {
99

1010
private Logger log = Logger.getLogger(CodeineUncaughtExceptionHandler.class);
@@ -17,7 +17,7 @@ public CodeineUncaughtExceptionHandler() {
1717
@Override
1818
public void uncaughtException(Thread t, Throwable e) {
1919
try {
20-
System.out.println("Uncaught exception!");
20+
System.err.println("Uncaught exception!");
2121
if (!errorPrintedToOut) {
2222
errorPrintedToOut = true;
2323
e.printStackTrace();
@@ -43,33 +43,33 @@ private void addExceptionInfo(Throwable e) {
4343
// public static void main(String[] args) {
4444
//
4545
// }
46-
// public static void main(String[] args) {
47-
// BasicConfigurator.configure();
48-
// Thread.setDefaultUncaughtExceptionHandler(new CodeineUncaughtExceptionHandler());
49-
// throw new RuntimeException() {
50-
// private static final long serialVersionUID = 1L;
51-
//
52-
// @Override
53-
// public String getMessage() {
54-
// overflow();
55-
// return "";
56-
// }
57-
//
58-
// @Override
59-
// public void printStackTrace(java.io.PrintWriter s) {
60-
// overflow();
61-
// }
62-
//
63-
// @Override
64-
// public void printStackTrace() {
65-
// overflow();
66-
// }
67-
//
68-
// private void overflow() {
69-
// overflow();
70-
// }
71-
//
72-
// };
73-
// }
46+
public static void main(String[] args) {
47+
BasicConfigurator.configure();
48+
Thread.setDefaultUncaughtExceptionHandler(new CodeineUncaughtExceptionHandler());
49+
throw new RuntimeException() {
50+
private static final long serialVersionUID = 1L;
51+
52+
@Override
53+
public String getMessage() {
54+
overflow();
55+
return "";
56+
}
57+
58+
@Override
59+
public void printStackTrace(java.io.PrintWriter s) {
60+
overflow();
61+
}
62+
63+
@Override
64+
public void printStackTrace() {
65+
overflow();
66+
}
67+
68+
private void overflow() {
69+
overflow();
70+
}
71+
72+
};
73+
}
7474

7575
}

0 commit comments

Comments
 (0)