Handles exceptions on the EDT.
| 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected