swing uncaughtexceptionhandler

后端 未结 1 2055
南旧
南旧 2021-01-15 12:20

I am trying to build a general exception handler for a swing application as described here: http://www.javaspecialists.eu/archive/Issue081.html

I work in jython (pyt

相关标签:
1条回答
  • 2021-01-15 12:54

    If you have Java 5 or higher, you can also use Thread.setDefaultUncaughtExceptionHandler(), which is also described in a newer "Java Specialists' Newsletter":

    http://www.javaspecialists.eu/archive/Issue089.html

    And here is the newest Java 7 version:

    http://www.javaspecialists.eu/archive/Issue196.html

    Also see this: Why bother with setting the "sun.awt.exception.handler" property?

    EDIT: This is how I use Thread.setDefaultUncaughtExceptionHandler (in Java...):

    public static void setupGlobalExceptionHandling() {
        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
            @Override
            public void uncaughtException(Thread t, Throwable e) {
                handleException(e);
            }
        });
    }
    
    0 讨论(0)
提交回复
热议问题