|
Re: How to shutdown on error [message #488812 is a reply to message #488508] |
Wed, 30 September 2009 10:55 |
Mark Miller Messages: 5 Registered: July 2009 |
Junior Member |
|
|
I use the following :
Let the bundle throw the exception so that it is unhandled.
in the IApplication start method, after the createDisplay but before createAndRunWorkbench
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
handleException(t, e);
}
});
// This is the error handler
private void handleException(final Thread t, final Throwable e) {
e.printStackTrace();
final Display display = Display.getDefault();
if (display.getThread() != t) {
display.syncExec(new Runnable() {
@Override
public void run() {
Status status = new Status(Status.ERROR, "app", e.getLocalizedMessage(), e);
int openError = ErrorDialog.openError(
display.getActiveShell(),
"Error - Epos will close",
"Could not handle the following error",
status);
if (openError == Window.OK) {
PlatformUI.getWorkbench().close();
}
}
});
}
}
[Updated on: Wed, 30 September 2009 10:56] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 1.53209 seconds