Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java @ 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 | 347cf4a5a486 |
children | 854312c0528c |
line wrap: on
line diff
--- 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.