Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java @ 3989:ccac1279eb41
More robust exception handler (#897)
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Sun, 30 Sep 2012 15:58:13 +0200 |
parents | 6cc5186b9b48 |
children | 145980c21700 |
comparison
equal
deleted
inserted
replaced
3988:090fea205d1d | 3989:ccac1279eb41 |
---|---|
3 import com.google.gwt.core.client.EntryPoint; | 3 import com.google.gwt.core.client.EntryPoint; |
4 import com.google.gwt.core.client.GWT; | 4 import com.google.gwt.core.client.GWT; |
5 import com.google.gwt.event.shared.UmbrellaException; | 5 import com.google.gwt.event.shared.UmbrellaException; |
6 import com.google.gwt.user.client.rpc.AsyncCallback; | 6 import com.google.gwt.user.client.rpc.AsyncCallback; |
7 import com.google.gwt.xml.client.XMLParser; | 7 import com.google.gwt.xml.client.XMLParser; |
8 | |
8 import com.smartgwt.client.util.SC; | 9 import com.smartgwt.client.util.SC; |
9 import com.smartgwt.client.widgets.HTMLPane; | 10 import com.smartgwt.client.widgets.HTMLPane; |
10 import com.smartgwt.client.widgets.Window; | 11 import com.smartgwt.client.widgets.Window; |
11 import com.smartgwt.client.widgets.events.CloseClickEvent; | 12 import com.smartgwt.client.widgets.events.CloseClickEvent; |
12 import com.smartgwt.client.widgets.events.CloseClickHandler; | 13 import com.smartgwt.client.widgets.events.CloseClickHandler; |
101 | 102 |
102 /** This list is used to track the opened projects. */ | 103 /** This list is used to track the opened projects. */ |
103 protected List<String> openProjects; | 104 protected List<String> openProjects; |
104 | 105 |
105 | 106 |
107 protected String getExceptionString(Throwable caught) { | |
108 try { | |
109 return MSG.getString(caught.getMessage()); | |
110 } | |
111 catch(MissingResourceException ex) { | |
112 // There are some server error exceptions with | |
113 // varying text messages that cannot be localized | |
114 // easily. In this rare cases, use the plain | |
115 // exception message. | |
116 GWT.log("Missing resource for: " + caught.getMessage()); | |
117 return caught.getLocalizedMessage(); | |
118 } | |
119 } | |
120 | |
106 /** | 121 /** |
107 * This is the entry point method. | 122 * This is the entry point method. |
108 */ | 123 */ |
109 @Override | 124 @Override |
110 public void onModuleLoad() { | 125 public void onModuleLoad() { |
145 | 160 |
146 userService.getCurrentUser(locale, new AsyncCallback<User>() { | 161 userService.getCurrentUser(locale, new AsyncCallback<User>() { |
147 @Override | 162 @Override |
148 public void onFailure(Throwable caught) { | 163 public void onFailure(Throwable caught) { |
149 GWT.log("Could not find a logged in user."); | 164 GWT.log("Could not find a logged in user."); |
150 String msg = caught.getLocalizedMessage(); | 165 String msg = getExceptionString(caught); |
151 try { | |
152 msg = MSG.getString(caught.getMessage()); | |
153 } | |
154 catch(MissingResourceException ex) { | |
155 // There are some server error exceptions with | |
156 // varying text messages that cannot be localized | |
157 // easily. In this rare cases, use the plain | |
158 // exception message. | |
159 GWT.log("Missing resource for: " + caught.getMessage()); | |
160 } | |
161 SC.warn(msg); | 166 SC.warn(msg); |
162 } | 167 } |
163 | 168 |
164 @Override | 169 @Override |
165 public void onSuccess(User user) { | 170 public void onSuccess(User user) { |
275 | 280 |
276 riverService.list(locale, new AsyncCallback<River[]>() { | 281 riverService.list(locale, new AsyncCallback<River[]>() { |
277 @Override | 282 @Override |
278 public void onFailure(Throwable caught) { | 283 public void onFailure(Throwable caught) { |
279 GWT.log("Could not recieve a list of rivers."); | 284 GWT.log("Could not recieve a list of rivers."); |
280 SC.warn(MSG.getString(caught.getMessage())); | 285 SC.warn(getExceptionString(caught)); |
281 } | 286 } |
282 | 287 |
283 @Override | 288 @Override |
284 public void onSuccess(River[] newRivers) { | 289 public void onSuccess(River[] newRivers) { |
285 GWT.log("Retrieved " + newRivers.length + " new rivers."); | 290 GWT.log("Retrieved " + newRivers.length + " new rivers."); |
355 | 360 |
356 describeCollectionService.describe(collectionID, locale, | 361 describeCollectionService.describe(collectionID, locale, |
357 new AsyncCallback<Collection>() { | 362 new AsyncCallback<Collection>() { |
358 @Override | 363 @Override |
359 public void onFailure(Throwable caught) { | 364 public void onFailure(Throwable caught) { |
360 SC.warn(MSG.getString(caught.getMessage())); | 365 SC.warn(getExceptionString(caught)); |
361 } | 366 } |
362 | 367 |
363 @Override | 368 @Override |
364 public void onSuccess(Collection c) { | 369 public void onSuccess(Collection c) { |
365 final Collection collection = c; | 370 final Collection collection = c; |
392 item.hash(), | 397 item.hash(), |
393 new AsyncCallback<Artifact>() { | 398 new AsyncCallback<Artifact>() { |
394 @Override | 399 @Override |
395 public void onFailure(Throwable caught) { | 400 public void onFailure(Throwable caught) { |
396 unlockProject(collectionID); | 401 unlockProject(collectionID); |
397 SC.warn(MSG.getString(caught.getMessage())); | 402 SC.warn(getExceptionString(caught)); |
398 } | 403 } |
399 | 404 |
400 @Override | 405 @Override |
401 public void onSuccess(Artifact artifact) { | 406 public void onSuccess(Artifact artifact) { |
402 CollectionView view = new CollectionView( | 407 CollectionView view = new CollectionView( |
433 artifactService.create(locale, factory, null, | 438 artifactService.create(locale, factory, null, |
434 new AsyncCallback<Artifact>() { | 439 new AsyncCallback<Artifact>() { |
435 @Override | 440 @Override |
436 public void onFailure(Throwable caught) { | 441 public void onFailure(Throwable caught) { |
437 GWT.log("Could not create the new artifact."); | 442 GWT.log("Could not create the new artifact."); |
438 SC.warn(MSG.getString(caught.getMessage())); | 443 SC.warn(getExceptionString(caught)); |
439 } | 444 } |
440 | 445 |
441 @Override | 446 @Override |
442 public void onSuccess(Artifact artifact) { | 447 public void onSuccess(Artifact artifact) { |
443 GWT.log("Successfully created a new artifact."); | 448 GWT.log("Successfully created a new artifact."); |
463 collectionService.create(locale, user.identifier(), | 468 collectionService.create(locale, user.identifier(), |
464 new AsyncCallback<Collection>() { | 469 new AsyncCallback<Collection>() { |
465 @Override | 470 @Override |
466 public void onFailure(Throwable caught) { | 471 public void onFailure(Throwable caught) { |
467 GWT.log("Could not create new collection."); | 472 GWT.log("Could not create new collection."); |
468 SC.warn(MSG.getString(caught.getMessage())); | 473 SC.warn(getExceptionString(caught)); |
469 } | 474 } |
470 | 475 |
471 @Override | 476 @Override |
472 public void onSuccess(Collection collection) { | 477 public void onSuccess(Collection collection) { |
473 GWT.log("Successfully created a new collection."); | 478 GWT.log("Successfully created a new collection."); |
476 col, locale, riv, ref, | 481 col, locale, riv, ref, |
477 new AsyncCallback<Artifact>() { | 482 new AsyncCallback<Artifact>() { |
478 @Override | 483 @Override |
479 public void onFailure(Throwable caught) { | 484 public void onFailure(Throwable caught) { |
480 GWT.log("Could not create the new artifact."); | 485 GWT.log("Could not create the new artifact."); |
481 SC.warn(MSG.getString(caught.getMessage())); | 486 SC.warn(getExceptionString(caught)); |
482 } | 487 } |
483 | 488 |
484 @Override | 489 @Override |
485 public void onSuccess(Artifact artifact) { | 490 public void onSuccess(Artifact artifact) { |
486 GWT.log("Successfully created a new artifact."); | 491 GWT.log("Successfully created a new artifact."); |