Revision 707b6237
Added by Niels Hoffmann over 12 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java | ||
---|---|---|
162 | 162 |
.getActivePage() |
163 | 163 |
.showView(id, null, IWorkbenchPage.VIEW_VISIBLE); |
164 | 164 |
} catch (PartInitException e) { |
165 |
error(AbstractUtility.class, "Could not open view: " + id, e);
|
|
166 |
throw new RuntimeException(e);
|
|
165 |
errorDialog("Error opening view", AbstractUtility.class, "Could not open view: " + id, e);
|
|
166 |
return null;
|
|
167 | 167 |
} |
168 | 168 |
} |
169 | 169 |
|
... | ... | |
354 | 354 |
Display.getDefault().asyncExec(new Runnable() { |
355 | 355 |
|
356 | 356 |
public void run() { |
357 |
MessageDialog.openError(getShell(), title, message); |
|
357 |
MessageDialog.openError(getShell(), title, message + getCauseRecursively(t));
|
|
358 | 358 |
Class<? extends Object> clazz = source != null ? source |
359 | 359 |
.getClass() : this.getClass(); |
360 | 360 |
error(clazz, message, t); |
361 | 361 |
} |
362 |
|
|
363 |
private String getCauseRecursively(Throwable t) { |
|
364 |
if(t == null){ |
|
365 |
return null; |
|
366 |
} |
|
367 |
|
|
368 |
if(t.getCause() != null){ |
|
369 |
return getCauseRecursively(t.getCause()); |
|
370 |
}else{ |
|
371 |
return String.format("\n\nException: %s\nMessage: %s", t.getClass().getSimpleName(), t.getMessage()); |
|
372 |
} |
|
373 |
|
|
374 |
} |
|
362 | 375 |
}); |
363 | 376 |
} |
364 | 377 |
|
... | ... | |
427 | 440 |
public void run(IProgressMonitor monitor) |
428 | 441 |
throws InvocationTargetException, InterruptedException { |
429 | 442 |
monitor.beginTask(operation.getLabel(), 100); |
430 |
IStatus status; |
|
443 |
IStatus status = Status.CANCEL_STATUS;
|
|
431 | 444 |
try { |
432 | 445 |
operation.addContext(IOperationHistory.GLOBAL_UNDO_CONTEXT); |
433 | 446 |
status = getOperationHistory().execute(operation, monitor, |
434 | 447 |
uiInfoAdapter); |
435 | 448 |
} catch (ExecutionException e) { |
436 |
throw new RuntimeException(e); |
|
449 |
errorDialog("Error executing operation", getClass(), String.format("An error occured while executing %s.", operation.getLabel()), e); |
|
450 |
} finally { |
|
451 |
monitor.done(); |
|
437 | 452 |
} |
438 |
monitor.done(); |
|
453 |
|
|
439 | 454 |
String statusString = status.equals(Status.OK_STATUS) ? "completed" |
440 | 455 |
: "cancelled"; |
441 | 456 |
setStatusLine(operation.getLabel() + " " + statusString + "."); |
... | ... | |
445 | 460 |
|
446 | 461 |
try { |
447 | 462 |
runInUI(runnable, null); |
448 |
} catch (InvocationTargetException e) { |
|
449 |
throw new RuntimeException(e); |
|
450 |
} catch (InterruptedException e) { |
|
451 |
throw new RuntimeException(e); |
|
463 |
} catch (Exception e) { |
|
464 |
errorDialog("Error executing operation", AbstractUtility.class, "An error occured while executing " + operation.getLabel(), e); |
|
452 | 465 |
} |
453 | 466 |
|
454 | 467 |
// // Start the main progress monitor. |
... | ... | |
726 | 739 |
getLog4JLogger(source).warn(message); |
727 | 740 |
log(status); |
728 | 741 |
} |
742 |
|
|
743 |
public static void warn(Class source, Throwable t) { |
|
744 |
IStatus status = new Status(IStatus.WARNING, getPluginId(), t.getMessage(), t); |
|
745 |
getLog4JLogger(source).warn(t); |
|
746 |
log(status); |
|
747 |
} |
|
729 | 748 |
|
730 | 749 |
/** |
731 | 750 |
* <p> |
Also available in: Unified diff
Merged with trunk