Handling exceptions in SwingWorker
- From: "Efi Merdler" <fooshm@xxxxxxxxx>
- Date: 26 Feb 2007 08:37:48 -0800
Hello,
I didn't find any information on this subject.
Let's assume that I have an exception while running my background
method, what are my available options :
1. Handle the exception from within the background method, sometimes
not possible especially if it requires handling GUI.
2. Create a getter method called getException() that returns the
exception if one exists and null if none exists.
The background method can return some kind of a value indicating that
something wrong happened like null (although not always possible).
You have to make sure that the background methods terminates quietly
i.e. does not allow the exception to propagate up but to catch it.
In the done() method which is called after background method returned
you can check getException() and do what ever you think you should do
(logging, display an error message etc...)
Does the above solution sounds ok ?
Thanks,
Efi
.
- Follow-Ups:
- Re: Handling exceptions in SwingWorker
- From: Michael Rauscher
- Re: Handling exceptions in SwingWorker
- Prev by Date: Set the Cursor for Anactive Frames
- Next by Date: JList as Jtable Render and editor
- Previous by thread: Set the Cursor for Anactive Frames
- Next by thread: Re: Handling exceptions in SwingWorker
- Index(es):
Relevant Pages
|