I'm trying to implement a "complete" uncaught exception handler, allowing to also catch EDT exceptions in Clojure.
I'm trying to implement the class from the accepted answer (with 15+ upvotes) from here:
How can i catch Event Dispatch Thread (EDT) exceptions?
Here's the part that I'd like to port to Clojure:
public static class ExceptionHandler implements Thread.UncaughtExceptionHandler {
public void handle(Throwable thrown) {
// for EDT exceptions
handleException(Thread.currentThread().getName(), thrown);
}
public void uncaughtException(Thread thread, Throwable thrown) {
// for other uncaught exceptions
handleException(thread.getName(), thrown);
}
protected void handleException(String tname, Throwable thrown) {
System.err.println("Exception on " + tname);
thrown.printStackTrace();
}
}
public static void main(String[] args) {
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler());
System.setProperty("sun.awt.exception.handler",
ExceptionHandler.class.getName());
However I'm stuck. The UncaughtExceptionHandler
is a public interface defined inside Thread and I can't seem to proxy it from Clojure.
I don't know what to import nor how to implement this.
Any help would be greatly appreciated because I'm having exceptions that I can seem to diagnose because they're "lost" somewhere in the EDT (and the EDT is automatically fixed / restarted).