Handling errors from a launched program
If you have defined your own type of launch configuration, it's likely that
you will want to handle errors or other status information that arises during the
running of the program. For example, you may want to prompt or alert the
user when certain types of errors occur during a launch, or provide information
messages for certain status changes in the program. Since it's good
practice to separate UI handling from core function, you do not want to have
direct references from your launch delegate to status handling classes.
This problem is addressed by the
org.eclipse.debug.core.statusHandlers
extension point. It allows you to associate a status handler with a
specific status code. Using this extension point, you can define all of
the possible status and error codes in your launch delegate and core classes,
while registering unique handlers for the different status codes from another
plug-in.
The extension point does not designate any association between a status
handler and a launch configuration. It is up to the implementation of the
launch delegate to detect errors, find the appropriate status handler, and
invoke it. The extension merely provides a registry so that the status
handlers can be found for particular status codes.
DebugPlugin
provides a utility method for obtaining a specific status handler.
IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status);
Status handlers should implement
IStatusHandler.
The status handling class is specified in the extension definition, along with
its associated status code and the plug-in that is expected to generate the
status codes.
The following markup shows how the Java tools declare status handlers:
<extension point = "org.eclipse.debug.core.statusHandlers">
<statusHandler
id="org.eclipse.jdt.debug.ui.statusHandler.vmConnectTimeout"
class="org.eclipse.jdt.internal.debug.ui.launcher.VMConnectTimeoutStatusHandler"
plugin ="org.eclipse.jdt.launching"
code="117">
</statusHandler>
...
</extension>