Handling exceptions in SwingWorker



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

.



Relevant Pages

  • Re: Cannot display throw new exception error message
    ... you can't see your error message, because your code doesn't reach the ... line where you throw your Exception. ... To display your custom message, your openFilemethod should look like: ... If you would have had a look at the FileReader API documentation, ...
    (comp.lang.java.programmer)
  • Should throw exception when validating data?
    ... i'm wondering if it is preferred practice to throw exception in this ... should try to never throw an exception in circumstances where you can do ... with the error message so that it can then be accessed in the UI to display ...
    (microsoft.public.dotnet.languages.csharp)
  • Displaying error messages
    ... I'm new to .NET and web development so please forgive. ... to display an error message, ... I want to inform the user that I just caught this exception. ...
    (microsoft.public.dotnet.general)
  • Re: Displaying error messages
    ... > I'm new to .NET and web development so please forgive. ... > to display an error message, ... I want to inform the user that I just caught this exception. ...
    (microsoft.public.dotnet.general)
  • Updating Access 2000 mdb with asp.net vb Microsoft.Jet.OLEDB.4.0
    ... and produces no error message either. ... display look fine. ... WHERE chain=@chain", objConn) ... Catch ex As Exception ...
    (microsoft.public.data.oledb)