better error handling with network calls
authorpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 24 Aug 2006 17:08:11 +0000 (17:08 +0000)
committerpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 24 Aug 2006 17:08:11 +0000 (17:08 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5656 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/util/network.js

index db1a4a6..cfa859e 100644 (file)
@@ -142,8 +142,19 @@ util.network.prototype = {
                                r = 1;
 
                        } else {
-                               try { obj.error.sdump('D_SES_ERROR','method: ' + name + '\nparams: '+ js2JSON(params) + '\nReturned null with a NETWORK_FAILURE = ' + obj.NETWORK_FAILURE + ( typeof obj.NETWORK_FAILURE.status == 'function' ? '.status() == ' + obj.NETWORK_FAILURE.status() : '') + '\n'); } catch(E) { alert(E); }
-                               r = obj.error.yns_alert('Network/server failure.  Please check your Internet connection to ' + data.server_unadorned + ' and choose Retry Network.  If you need to enter Offline Mode, choose Proceed Offline in this and subsequent dialogs.  If you believe this error is due to a bug in Evergreen and not network problems, please contact your helpdesk or friendly Evergreen admins, and give them this message: method=' + name + ' params=' + js2JSON(params) + ' thrown = ' + obj.NETWORK_FAILURE + (typeof obj.NETWORK_FAILURE.status == 'function' ? '.status() == ' + obj.NETWORK_FAILURE.status() : '') + '.','Network Failure','Retry Network','Proceed Offline',null,'Check here to confirm this message');
+
+                               var network_failure_string;
+                               var network_failure_status_string;
+                               var msg;
+
+                               try { network_failure_string = String( obj.NETWORK_FAILURE ); } catch(E) { network_failure_string = E; }
+                               try { network_failure_status_string = typeof obj.NETWORK_FAILURE == 'object' && typeof obj.NETWORK_FAILURE.status == 'function' ? network_failure_status_string = obj.NETWORK_FAILURE.status() : network_failure_status_string = ''; } catch(E) { network_failure_string = E; }
+                               
+                               try { msg = 'Network/server failure.  Please check your Internet connection to ' + data.server_unadorned + ' and choose Retry Network.  If you need to enter Offline Mode, choose Proceed Offline in this and subsequent dialogs.  If you believe this error is due to a bug in Evergreen and not network problems, please contact your helpdesk or friendly Evergreen admins, and give them this information:\nmethod=' + name + '\nparams=' + js2JSON(params) + '\nTHROWN:\n' + network_failure_string + '\nSTATUS:\n' + network_failure_status_string; } catch(E) { msg = E; }
+
+                               try { obj.error.sdump('D_SES_ERROR',msg); } catch(E) { alert(E); }
+
+                               r = obj.error.yns_alert(msg,'Network Failure','Retry Network','Proceed Offline',null,'Check here to confirm this message');
                                if (r == 1) {
                                        data.proceed_offline = true; data.stash('proceed_offline');
                                        dump('Remembering proceed_offline for 200000 ms.\n');