changeset 605:9e30c776cbef

Improved the exception handling. flys-client/trunk@2212 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 23 Jun 2011 09:22:54 +0000
parents 84d3c5fde5bb
children 69c0a6ecad57
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties
diffstat 6 files changed, 92 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Thu Jun 23 09:11:54 2011 +0000
+++ b/flys-client/ChangeLog	Thu Jun 23 09:22:54 2011 +0000
@@ -1,3 +1,16 @@
+2011-06-23  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/FLYSConstants.properties,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants.java:
+	  Added more i18n strings for the project list and error messages.
+
+	* src/main/java/de/intevation/flys/client/client/FLYS.java: Added a
+	  handler that catches uncaught exceptions. Those exceptions are displayed
+	  using a new method showWarning(Throwable t). This method brings up a
+	  Window that displays the stacktrace of the exceptions.
+
 2011-06-23	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* pom.xml: Added dependency to Apache Commons Lang 2.6 http://commons.apache.org/lang/
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java	Thu Jun 23 09:11:54 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java	Thu Jun 23 09:22:54 2011 +0000
@@ -2,14 +2,18 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Set;
 
 import com.google.gwt.core.client.EntryPoint;
 import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.shared.UmbrellaException;
 import com.google.gwt.user.client.rpc.AsyncCallback;
 import com.google.gwt.user.client.ui.RootPanel;
 import com.google.gwt.xml.client.XMLParser;
 
 import com.smartgwt.client.util.SC;
+import com.smartgwt.client.widgets.Window;
+import com.smartgwt.client.widgets.HTMLPane;
 import com.smartgwt.client.widgets.layout.VLayout;
 import com.smartgwt.client.widgets.layout.HLayout;
 import com.smartgwt.client.widgets.events.CloseClickHandler;
@@ -100,6 +104,12 @@
     public void onModuleLoad() {
         openProjects = new ArrayList<String>();
 
+        GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() {
+            public void onUncaughtException(Throwable e) {
+                showWarning(e);
+            }
+        });
+
         VLayout vertical = new VLayout();
         vertical.setLayoutMargin(1);
         vertical.setWidth100();
@@ -153,6 +163,40 @@
     }
 
 
+    public void showWarning(Throwable e) {
+        StringBuilder sb = new StringBuilder();
+        sb.append("<tt>");
+
+        if (e instanceof UmbrellaException) {
+            UmbrellaException u = (UmbrellaException) e;
+            Set<Throwable> throwables = u.getCauses();
+
+            for (Throwable t: throwables) {
+                sb.append(t.getLocalizedMessage());
+                sb.append("<br>");
+            }
+        }
+        else {
+            sb.append(e.getLocalizedMessage());
+        }
+
+        sb.append("</tt>");
+
+        Window w = new Window();
+        w.setTitle(MSG.unexpected_exception());
+        w.setWidth(550);
+        w.setHeight(300);
+        w.centerInPage();
+        w.setCanDragResize(true);
+
+        HTMLPane p = new HTMLPane();
+        p.setContents(sb.toString());
+
+        w.addItem(p);
+        w.show();
+    }
+
+
     /**
      * This method should be called at system start. It initialzes the client
      * configuration.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Thu Jun 23 09:11:54 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Thu Jun 23 09:22:54 2011 +0000
@@ -8,6 +8,8 @@
  */
 public interface FLYSConstants extends ConstantsWithLookup {
 
+    String unexpected_exception();
+
     String title();
 
     String fullname();
@@ -26,6 +28,18 @@
 
     String manage_projects();
 
+    String favorite_tooltip();
+
+    String favorite_tooltip_meaning();
+
+    String projectlist_creationTime();
+
+    String projectlist_title();
+
+    String projectlist_favorite();
+
+    String really_delete();
+
     String logout();
 
     String switch_language();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Thu Jun 23 09:11:54 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Thu Jun 23 09:22:54 2011 +0000
@@ -8,6 +8,12 @@
 delete_project = Delete Project
 rename_project = Rename Project
 manage_projects = Manage Projects
+favorite_tooltip = Permanently store?
+favorite_tooltip_meaning = Golden star: stored
+projectlist_creationTime = Creation time
+projectlist_title = Title
+projectlist_favorite = Permanent
+really_delete = Do you really want to delete this project?
 switch_language = German
 info = Info
 warning = Attention
@@ -100,6 +106,7 @@
 wst = WST
 chart_themepanel_header_themes = Theme
 
+unexpected_exception = There occured an unexpected exception
 error_read_minmax_values = Error while reading min/max values for the location input.
 error_validate_range = The value $1 needs to be smaller than $3 and bigger than $2.
 error_validate_lower_range = The lower value $1 needs to be bigger than $2.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Thu Jun 23 09:11:54 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Thu Jun 23 09:22:54 2011 +0000
@@ -8,6 +8,12 @@
 delete_project = Projekt l\u00f6schen
 rename_project = Projekt umbenennen
 manage_projects = Projekte verwalten
+favorite_tooltip = Dauerhaft speichern?
+favorite_tooltip_meaning = Goldener Stern: gespeichert
+projectlist_creationTime = Anlegezeitpunkt
+projectlist_title = Titel
+projectlist_favorite = Dauerhaft
+really_delete = Wollen Sie dieses Projekt wirklich l\u00f6schen?
 switch_language = Englisch
 info = Info
 warning = Achtung
@@ -100,6 +106,7 @@
 wst = WST
 chart_themepanel_header_themes = Thema
 
+unexpected_exception = Ein unerwarteter Fehler ist aufgetreten
 error_read_minmax_values = Fehler beim Lesen der min/max Werte. Es kann keine Validierung der eingegebenen Strecke durchgef\u00fchrt werden.
 error_validate_range = Der Wert $1 muss kleiner als $3 und gr\u00f6\u00dfer als $2 sein.
 error_validate_lower_range = Der untere Wert $1 muss gr\u00f6\u00dfer sein als $2.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Thu Jun 23 09:11:54 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Thu Jun 23 09:22:54 2011 +0000
@@ -8,6 +8,12 @@
 delete_project = Delete Project
 rename_project = Rename Project
 manage_projects = Manage Projects
+favorite_tooltip = Permanently store?
+favorite_tooltip_meaning = Golden star: stored
+projectlist_creationTime = Creation time
+projectlist_title = Title
+projectlist_favorite = Permanent
+really_delete = Do you really want to delete this project?
 switch_language = German
 info = Info
 warning = Attention
@@ -98,6 +104,7 @@
 wst = WST
 chart_themepanel_header_themes = Theme
 
+unexpected_exception = There occured an unexpected exception
 error_read_minmax_values = Error while reading min/max values for the location input.
 error_validate_range = The value $1 needs to be smaller than $3 and bigger than $2.
 error_validate_lower_range = The lower value $1 needs to be bigger than $2.

http://dive4elements.wald.intevation.org