use of org.eclipse.scout.rt.platform.exception.IProcessingStatus in project scout.rt by eclipse.
the class ClientExceptionHandler method showExceptionInternal.
protected void showExceptionInternal(final Throwable t) {
final IClientSession session = ClientSessionProvider.currentSession();
if (session == null) {
return;
}
if (session.getDesktop() == null || !session.getDesktop().isOpened()) {
return;
}
// Prevent loops while displaying the exception.
final Semaphore loopDetectionSemaphore = getLoopDetectionSemaphore(session);
if (loopDetectionSemaphore.tryAcquire()) {
try {
// Synchronize with the model thread if not applicable.
if (ModelJobs.isModelThread()) {
showException(t);
} else {
try {
ModelJobs.schedule(new IRunnable() {
@Override
public void run() throws Exception {
showException(t);
}
}, ModelJobs.newInput(ClientRunContexts.copyCurrent()).withExceptionHandling(null, true).withName("Visualizing PlatformException")).awaitDone();
} catch (final ThreadInterruptedError e) {
// NOSONAR
// NOOP
}
}
} finally {
loopDetectionSemaphore.release();
}
} else {
Exception e = new Exception("Stacktrace and suppressed exception");
// add original exception for analysis
e.addSuppressed(t);
LOG.warn("Loop detection in {}", getClass().getName(), e);
if (ModelJobs.isModelThread()) {
IMessageBox msgBox = MessageBoxes.createOk().withSeverity(IStatus.ERROR).withHeader(TEXTS.get("Error"));
if (t instanceof VetoException) {
IProcessingStatus status = ((VetoException) t).getStatus();
msgBox.withHeader(status.getTitle()).withBody(status.getBody());
}
msgBox.show();
}
}
}
Aggregations