From 61d2b8b9f0afa2a53afeec490292e9f095972939 Mon Sep 17 00:00:00 2001
From: phasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Wed, 7 Oct 2009 15:34:41 +0000
Subject: [PATCH] remnants of some troubleshooting; useful to keep these in
 here

git-svn-id: svn://svn.open-ils.org/ILS/trunk@14290 dcc99617-32d9-48b4-a31d-7c20da2025e4
---
 .../staff_client/chrome/content/OpenILS/data.js    |  9 ++++-
 .../chrome/content/OpenILS/global_util.js          | 45 ++++++++++++++--------
 .../xul/staff_client/chrome/content/util/error.js  | 28 ++++++++------
 .../staff_client/chrome/content/util/network.js    | 13 +++++--
 4 files changed, 63 insertions(+), 32 deletions(-)

diff --git a/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js b/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js
index 57a3e2b9e5..17b5dae82e 100644
--- a/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js
+++ b/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js
@@ -3,8 +3,13 @@ dump('entering OpenILS/data.js\n');
 if (typeof OpenILS == 'undefined') OpenILS = {};
 OpenILS.data = function () {
 
-	JSAN.use('util.error'); this.error = new util.error();
-	JSAN.use('util.network'); this.network = new util.network();
+    try {
+        JSAN.use('util.error'); this.error = new util.error();
+        JSAN.use('util.network'); this.network = new util.network();
+    } catch(E) {
+        alert(location.href + '\nError in OpenILS.data constructor: ' + E);
+        throw(E);
+    }
 
 	return this;
 }
diff --git a/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js b/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js
index 734f424aa6..04bec66f14 100644
--- a/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js
+++ b/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js
@@ -1,21 +1,34 @@
 	function $(id) { return document.getElementById(id); }
 
-	function ses(a) {
-		JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
-		switch(a) {
-            case 'staff_id' : return data.list.au[0].id(); break;
-            case 'staff_usrname' : return data.list.au[0].usrname(); break;
-            case 'ws_ou' :
-                return data.list.au[0].ws_ou();
-            break;
-			case 'authtime' :
-				return data.session.authtime;
-			break;
-			case 'key':
-			default:
-				return data.session.key;
-			break;
-		}
+	function ses(a,params) {
+        try {
+            if (!params) params = {};
+            var data;
+            if (params.data) {
+                data = params.data; data.stash_retrieve();
+            } else {
+                // This has been breaking in certain contexts, with an internal instantiation of util.error failing because of util.error being an object instead of the constructor function it should be
+                JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.stash_retrieve();
+            }
+
+            switch(a) {
+                case 'staff_id' : return data.list.au[0].id(); break;
+                case 'staff_usrname' : return data.list.au[0].usrname(); break;
+                case 'ws_ou' :
+                    return data.list.au[0].ws_ou();
+                break;
+                case 'authtime' :
+                    return data.session.authtime;
+                break;
+                case 'key':
+                default:
+                    return data.session.key;
+                break;
+            }
+        } catch(E) {
+            alert(location.href + '\nError in global_utils.js, ses(): ' + E);
+            throw(E);
+        }
 	}
 
 	function font_helper() {
diff --git a/Open-ILS/xul/staff_client/chrome/content/util/error.js b/Open-ILS/xul/staff_client/chrome/content/util/error.js
index 758b1557b4..3c23d8fe55 100644
--- a/Open-ILS/xul/staff_client/chrome/content/util/error.js
+++ b/Open-ILS/xul/staff_client/chrome/content/util/error.js
@@ -3,20 +3,26 @@ dump('entering util/error.js\n');
 if (typeof util == 'undefined') util = {};
 util.error = function () {
 
-	try {
-		netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-		this.consoleService = Components.classes['@mozilla.org/consoleservice;1']
-			.getService(Components.interfaces.nsIConsoleService);
-	} catch(E) {
-		this.consoleDump = false;
-		dump('util.error constructor: ' + E + '\n');
-	}
+    try {
+
+        try {
+            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+            this.consoleService = Components.classes['@mozilla.org/consoleservice;1']
+                .getService(Components.interfaces.nsIConsoleService);
+        } catch(E) {
+            this.consoleDump = false;
+            dump('util.error constructor: ' + E + '\n');
+        }
+
+        this.sdump_last_time = new Date();
 
-	this.sdump_last_time = new Date();
+        this.OpenILS = {};
 
-	this.OpenILS = {};
+        JSAN.use('util.sound'); this.sound = new util.sound();
 
-	JSAN.use('util.sound'); this.sound = new util.sound();
+    } catch(E) {
+        alert('Error in util.error constructor: ' + E);
+    }
 
 	return this;
 };
diff --git a/Open-ILS/xul/staff_client/chrome/content/util/network.js b/Open-ILS/xul/staff_client/chrome/content/util/network.js
index 9a4dbc9463..e3f77fd680 100644
--- a/Open-ILS/xul/staff_client/chrome/content/util/network.js
+++ b/Open-ILS/xul/staff_client/chrome/content/util/network.js
@@ -6,10 +6,17 @@ var offlineStrings;
 if (typeof util == 'undefined') util = {};
 util.network = function () {
 
-	JSAN.use('util.error'); this.error = new util.error();
-	JSAN.use('util.sound'); this.sound = new util.sound();
+    try {
 
-    offlineStrings = document.getElementById('offlineStrings');
+        JSAN.use('util.error'); this.error = new util.error();
+        JSAN.use('util.sound'); this.sound = new util.sound();
+
+        offlineStrings = document.getElementById('offlineStrings');
+
+    } catch(E) {
+        alert('error in util.network constructor: ' + E);
+        throw(E);
+    }
 
 	return this;
 };
-- 
2.11.0