MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / ExceptionHandler

Class ExceptionHandler

ij/src/main/java/ij/ImageJ.java:1069–1098  ·  view source on GitHub ↗

Handles exceptions on the EDT.

Source from the content-addressed store, hash-verified

1067
1068 /** Handles exceptions on the EDT. */
1069 public static class ExceptionHandler implements Thread.UncaughtExceptionHandler {
1070
1071 // for EDT exceptions
1072 public void handle(Throwable thrown) {
1073 handleException(Thread.currentThread().getName(), thrown);
1074 }
1075
1076 // for other uncaught exceptions
1077 public void uncaughtException(Thread thread, Throwable thrown) {
1078 handleException(thread.getName(), thrown);
1079 }
1080
1081 @AstroImageJ(reason = "Duplicate stacktrace to log file", modified = true)
1082 protected void handleException(String tname, Throwable e) {
1083 if (Macro.MACRO_CANCELED.equals(e.getMessage()))
1084 return;
1085 CharArrayWriter caw = new CharArrayWriter();
1086 PrintWriter pw = new PrintWriter(caw);
1087 e.printStackTrace(pw);
1088 String s = caw.toString();
1089 if (s!=null && s.contains("ij.")) {
1090 if (IJ.getInstance()!=null)
1091 s = IJ.getInstance().getInfo()+"\n"+s;
1092 IJ.log(s);
1093 }
1094
1095 e.printStackTrace();
1096 }
1097
1098 } // inner class ExceptionHandler
1099}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected