So far, the code has been using an information dialog as the demonstration of the handler. There's an equivalent method that can be used to create an error message instead. Instead of calling MessageDialog.openInformation()
, there's an openError()
method, which presents the same kind of dialog, but with an error message instead:
Using dialogs to report errors may be useful for certain environments, but unless the user has just invoked something (and the UI is blocked while doing it), reporting errors via a dialog is not a very useful thing to do. Instead, Eclipse offers a standard way to encapsulate both success and failure, in the Status
object and the interface IStatus
that it implements. When a Job
completes, it returns an IStatus
object to denote success or failure of the Job
execution.
Introduce an error into the
run()
method ofHelloHandler
, whch will generate aNullPointerException
. Add acatch
to the existingtry
block and use that to return an error...