changeset 3989:ccac1279eb41

More robust exception handler (#897)
author Christian Lins <christian.lins@intevation.de>
date Sun, 30 Sep 2012 15:58:13 +0200
parents 090fea205d1d
children 31aaabe34774
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java
diffstat 2 files changed, 27 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Sun Sep 30 15:32:47 2012 +0200
+++ b/flys-client/ChangeLog	Sun Sep 30 15:58:13 2012 +0200
@@ -1,3 +1,8 @@
+2012-09-30	Christian Lins	<christian.lins@intevation.de>
+
+	* flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java:
+	  Make exception handler more robust regarding unexpected exceptions (#897).
+
 2012-09-29	Christian Lins	<christian.lins@intevation.de>
 
 	* flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ManualPointsEditor.java,
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java	Sun Sep 30 15:32:47 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java	Sun Sep 30 15:58:13 2012 +0200
@@ -5,6 +5,7 @@
 import com.google.gwt.event.shared.UmbrellaException;
 import com.google.gwt.user.client.rpc.AsyncCallback;
 import com.google.gwt.xml.client.XMLParser;
+
 import com.smartgwt.client.util.SC;
 import com.smartgwt.client.widgets.HTMLPane;
 import com.smartgwt.client.widgets.Window;
@@ -103,6 +104,20 @@
     protected List<String> openProjects;
 
 
+    protected String getExceptionString(Throwable caught) {
+        try {
+            return MSG.getString(caught.getMessage());
+        }
+        catch(MissingResourceException ex) {
+            // There are some server error exceptions with
+            // varying text messages that cannot be localized
+            // easily. In this rare cases, use the plain
+            // exception message.
+            GWT.log("Missing resource for: " + caught.getMessage());
+            return caught.getLocalizedMessage();
+        }
+    }
+
     /**
      * This is the entry point method.
      */
@@ -147,17 +162,7 @@
             @Override
             public void onFailure(Throwable caught) {
                 GWT.log("Could not find a logged in user.");
-                String msg = caught.getLocalizedMessage();
-                try {
-                    msg = MSG.getString(caught.getMessage());
-                }
-                catch(MissingResourceException ex) {
-                    // There are some server error exceptions with
-                    // varying text messages that cannot be localized
-                    // easily. In this rare cases, use the plain
-                    // exception message.
-                    GWT.log("Missing resource for: " + caught.getMessage());
-                }
+                String msg = getExceptionString(caught);
                 SC.warn(msg);
             }
 
@@ -277,7 +282,7 @@
             @Override
             public void onFailure(Throwable caught) {
                 GWT.log("Could not recieve a list of rivers.");
-                SC.warn(MSG.getString(caught.getMessage()));
+                SC.warn(getExceptionString(caught));
             }
 
             @Override
@@ -357,7 +362,7 @@
             new AsyncCallback<Collection>() {
                 @Override
                 public void onFailure(Throwable caught) {
-                    SC.warn(MSG.getString(caught.getMessage()));
+                    SC.warn(getExceptionString(caught));
                 }
 
                 @Override
@@ -394,7 +399,7 @@
                             @Override
                             public void onFailure(Throwable caught) {
                                 unlockProject(collectionID);
-                                SC.warn(MSG.getString(caught.getMessage()));
+                                SC.warn(getExceptionString(caught));
                             }
 
                             @Override
@@ -435,7 +440,7 @@
                 @Override
                 public void onFailure(Throwable caught) {
                     GWT.log("Could not create the new artifact.");
-                    SC.warn(MSG.getString(caught.getMessage()));
+                    SC.warn(getExceptionString(caught));
                 }
 
                 @Override
@@ -465,7 +470,7 @@
                 @Override
                 public void onFailure(Throwable caught) {
                     GWT.log("Could not create new collection.");
-                    SC.warn(MSG.getString(caught.getMessage()));
+                    SC.warn(getExceptionString(caught));
                 }
 
                 @Override
@@ -478,7 +483,7 @@
                             @Override
                             public void onFailure(Throwable caught) {
                                 GWT.log("Could not create the new artifact.");
-                                SC.warn(MSG.getString(caught.getMessage()));
+                                SC.warn(getExceptionString(caught));
                             }
 
                             @Override

http://dive4elements.wald.intevation.org