Useful Eclipse Java Editor Templates: Error handling
So you are writing Eclipse Plugin code and have to catch exceptions? Ok, but what to do with them?
e.printStackTrace() is not very nice. And in order to report it to the user or to log it in the plugin’s log, you have to create an instance of Status first.
Here is a template you can use in your exception hander to save typing time:
Status ${status:newName(org.eclipse.core.runtime.Status)} = new Status(
IStatus.ERROR, ${plugin:link(Activator)}.PLUGIN_ID,
"Error while ${cause:link(evaluating)}",
${exception_variable_name}.getCause() == null ? ${exception_variable_name} : ${exception_variable_name}.getCause());
${plugin}.getDefault().getLog().log(${status});
ErrorDialog.openError(getShell(), "Error", "Error while ${cause}", ${status});Again, you can use this XML to import the template directly.




