# HG changeset patch # User Christian Lins # Date 1349013493 -7200 # Node ID ccac1279eb41b8395efaeee75725d1bb7250b80d # Parent 090fea205d1d74e84612a0ec5b4dfd806428e76c More robust exception handler (#897) diff -r 090fea205d1d -r ccac1279eb41 flys-client/ChangeLog --- 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 + + * 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 * flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ManualPointsEditor.java, diff -r 090fea205d1d -r ccac1279eb41 flys-client/src/main/java/de/intevation/flys/client/client/FLYS.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 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() { @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