if(statusAdapter.getStatus().matches(IStatus.ERROR)) {
Throwable t = statusAdapter.getStatus().getException();
- // NOTE : the global status handling mechanism in the case of
- // runtime exceptions is called twice, once by the application
- // throwing the exception and then by the rcp logging mechanism
- // The check below is to make sure that the same exception is
- // not shown twice in succession.
- if(t != null && previousT == t) {
- return;
- }
- previousT = t;
-
- if (t != null && t.getCause() instanceof PermissionDeniedException){
- MessagingUtils.informationDialog("Permission denied", MessagingUtils.PERMISSION_DENIED);
- }
- else if (t != null &&
- ( t instanceof NoHttpResponseException
- || t.getCause() instanceof CdmAuthenticationException
- || (t.getMessage() != null && t.getMessage().contains("status code = 403")))){
- MessagingUtils.informationDialog("Access denied", MessagingUtils.ACCESS_DENIED);
- }else
-
- // NOTE : Currently we only allow RuntimeExceptions since
- // allowing all kinds of exceptions would also include
- // those in generated status objects coming from from logging triggers
- // leading to a recursive infinite loop of :
- // initial exception thrown -> status handling -> dialog opening + logging of status ->
- // status handling -> dialog opening + logging of status ... and so on
- if(t != null &&
- t instanceof RuntimeException &&
- ! "Widget is disposed".equals(t.getMessage()) &&
- ! handleKnownRuntimeException(t,statusAdapter.getStatus().getPlugin())) {
-
- MessagingUtils.errorDialog("Error",
- null,
- MessagingUtils.UNEXPECTED_ERROR_MESSAGE,
- statusAdapter.getStatus().getPlugin(),
- t,
- true);
-
- } else if (t != null && ("Widget is disposed".equals(t.getMessage()))){
- MessagingUtils.warn(this.getClass(), t);
- if (PreferencesUtil.isShowUpWidgetIsDisposedMessages()){
- MessagingUtils.errorDialog("Widget is disposed",
- null,
- MessagingUtils.WIDGET_IS_DISPOSED_MESSAGE,
- statusAdapter.getStatus().getPlugin(),
- t,
- true);
- }
- }else {
- if (t != null){
- if (analyzeCauseExceptions(t)){
+ if (t != null){
+ // NOTE : the global status handling mechanism in the case of
+ // runtime exceptions is called twice, once by the application
+ // throwing the exception and then by the rcp logging mechanism.
+ // The check below is to make sure that the same exception is
+ // not shown twice in succession.
+ if(previousT == t) {
+ return;
+ }
+ previousT = t;
+
+ if (t.getCause() instanceof PermissionDeniedException){
+ MessagingUtils.informationDialog("Permission denied", MessagingUtils.PERMISSION_DENIED);
+ }
+ else if (t instanceof NoHttpResponseException
+ || t.getCause() instanceof CdmAuthenticationException
+ || (t.getMessage() != null && t.getMessage().contains("status code = 403"))){
+ MessagingUtils.informationDialog("Access denied", MessagingUtils.ACCESS_DENIED);
+ }else
+
+ // NOTE : Currently we only allow RuntimeExceptions since
+ // allowing all kinds of exceptions would also include
+ // those in generated status objects coming from from logging triggers
+ // leading to a recursive infinite loop of :
+ // initial exception thrown -> status handling -> dialog opening + logging of status ->
+ // status handling -> dialog opening + logging of status ... and so on
+ if(t instanceof RuntimeException &&
+ ! "Widget is disposed".equals(t.getMessage()) &&
+ ! handleKnownRuntimeException(t,statusAdapter.getStatus().getPlugin())) {
+
+ MessagingUtils.errorDialog("Error",
+ null,
+ MessagingUtils.UNEXPECTED_ERROR_MESSAGE,
+ statusAdapter.getStatus().getPlugin(),
+ t,
+ true);
+
+ } else if (("Widget is disposed".equals(t.getMessage()))){
+ MessagingUtils.warn(this.getClass(), t);
+ if (PreferencesUtil.isShowUpWidgetIsDisposedMessages()){
+ MessagingUtils.errorDialog("Widget is disposed",
+ null,
+ MessagingUtils.WIDGET_IS_DISPOSED_MESSAGE,
+ statusAdapter.getStatus().getPlugin(),
+ t,
+ true);
+ }
+ }else {
+ if (includesCause(t, OptionalDataException.class)){
MessagingUtils.warn(this.getClass(), MessagingUtils.RESTART_EDITOR_MESSAGE);
}
}
- }
+ }
}
}
/**
* analyzes whether the
- * @param t
- * @param class1
*/
- private <T extends Exception> boolean analyzeCauseExceptions(Throwable t) {
+ private <T extends Exception> boolean includesCause(Throwable t, Class<? extends Throwable> clazz) {
boolean result = false;
- if (t instanceof OptionalDataException || (t.getCause() != null && t.getCause() instanceof OptionalDataException)){
+ if (clazz.isAssignableFrom(t.getClass())){
return true;
}else if (t.getCause() != null){
- return analyzeCauseExceptions(t.getCause());
+ return includesCause(t.getCause(), clazz);
}
return result;
-
-
-
-// if (t instanceof OptionalDataException || (t.getCause() != null && t.getCause() instanceof OptionalDataException)){
-// return true;
-// }else if (t.getCause() != null){
-// return analyzeCauseExceptions(t.getCause());
-// }
-// return result;
-
}
private boolean handleKnownRuntimeException(Throwable t, String pluginId) {