#5209 Beautify error messages related to connection / access to remote server
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / model / MessagingUtils.java
index 36777e8ca31e1e9dbcf5e70aa73468a226b11902..3988724a78b83e8c7e6c6cd51feed0489130dcda 100644 (file)
@@ -31,6 +31,8 @@ public class MessagingUtils {
     public final static String UNEXPECTED_ERROR_MESSAGE = "This is an unexpected error.";
     public final static String CONTACT_MESSAGE = System.getProperty("line.separator") +  "Please contact EDIT Support (EditSupport@bgbm.org) with the error trace below (click on the 'Details' button).";
     public final static String DEFAULT_MESSAGE = "Error thrown but no associated message";
+    public final static String CONNECTION_FAILURE_MESSAGE = "The connection to the remote server has been broken";
+    public final static String REMOTE_ACCESS_FAILURE_MESSAGE = "Problem accessing remote server";
 
     /**
      * Gets the Log4J logger for a given class
@@ -253,14 +255,15 @@ public class MessagingUtils {
             final Throwable t,
             final List<String> contextInfo,
             final String message,
-            final MultiStatus status) {
+            final MultiStatus status,
+            final boolean showReason) {
 
         Display.getDefault().asyncExec(new Runnable() {
 
             @Override
             public void run() {
                 String stackTraceWithContext = getStackTraceAndContextInfo(t, contextInfo);
-                CdmErrorDialog ced = new CdmErrorDialog(AbstractUtility.getShell(), title, message, status, stackTraceWithContext);
+                CdmErrorDialog ced = new CdmErrorDialog(AbstractUtility.getShell(), title, message, status, stackTraceWithContext, showReason);
                 ced.open();
                 Class<? extends Object> clazz = source != null ? source.getClass() : this.getClass();
 
@@ -275,6 +278,15 @@ public class MessagingUtils {
         });
     }
 
+    public static void errorDialog(final String title,
+            final Object source,
+            final String message,
+            final String pluginId,
+            final Throwable t,
+            boolean addContactMesg) {
+        errorDialog(title, source, message, pluginId, t, addContactMesg, true);
+
+    }
     /**
      * Displays a {@link eu.etaxonomy.taxeditor.model.CdmErrorDialog}.
      *
@@ -289,7 +301,8 @@ public class MessagingUtils {
             final String message,
             final String pluginId,
             final Throwable t,
-            boolean addContactMesg) {
+            boolean addContactMesg,
+            boolean showReason) {
 
         Throwable throwable = t;
         StringBuffer sbStackTrace = new StringBuffer();
@@ -356,7 +369,7 @@ public class MessagingUtils {
                 throwable.toString(),
                 throwable);
 
-        errorDialog(title, source, throwable, contextInfo, finalMessage, ms);
+        errorDialog(title, source, throwable, contextInfo, finalMessage, ms, showReason);
     }
 
     /**