Home >Java >javaTutorial >How to Handle Exceptions Thrown by SwingWorker's Future?
Can't get ArrayIndexOutOfBoundsException from Future> and SwingWorker if thread starts Executor
SwingWorker does not expose any way to get an underlying exception. However, since SwingWorker provides a way to complete with a result using the done() method, you can rethrow the exception here, where it will be caught by the caller of the get() method on the Future.
// ... @Override protected void done() { if (str.equals("StartShedule")) { try { get(); } catch (InterruptedException ie) { ie.printStackTrace(); } catch (ExecutionException ee) { throw (ee).getCause(); } } }
The above is the detailed content of How to Handle Exceptions Thrown by SwingWorker's Future?. For more information, please follow other related articles on the PHP Chinese website!