From df6faee12f7ab66a3d68e4681073406d1b338c49 Mon Sep 17 00:00:00 2001 From: pines Date: Wed, 14 Feb 2007 14:26:04 +0000 Subject: [PATCH] handle error if open-ils.write_in_user_chrome_directory pref is not set at all git-svn-id: svn://svn.open-ils.org/ILS/trunk@6954 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/xul/staff_client/chrome/content/util/file.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/util/file.js b/Open-ILS/xul/staff_client/chrome/content/util/file.js index 79325fb9c7..ca57ff8f92 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/file.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/file.js @@ -29,10 +29,15 @@ util.file.prototype = { if (!fname) { fname = this.name; } else { this.name = fname; } if (!fname) throw('Must specify a filename.'); - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead UniversalFileRead"); - var pref = Components.classes["@mozilla.org/preferences-service;1"] - .getService(Components.interfaces.nsIPrefBranch); - if (!path && pref.getBoolPref("open-ils.write_in_user_chrome_directory")) path = 'uchrome'; + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead UniversalFileRead"); + var pref = Components.classes["@mozilla.org/preferences-service;1"] + .getService(Components.interfaces.nsIPrefBranch); + if (!path && pref.getBoolPref("open-ils.write_in_user_chrome_directory")) path = 'uchrome'; + } catch(E) { + // getBoolPref throws an exception if "open-ils.write_in_user_chrome_directory" is not defined at all + // in defaults/preferences/prefs.js + } switch(path) { case 'uchrome' : @@ -55,7 +60,7 @@ util.file.prototype = { return this._file; } catch(E) { - this.error.sdump('D_ERROR',this._file.path + '\nutil.file.get(): ' + E); + this.error.standard_unexpected_error_alert('error in util.file.get('+fname+','+path+')',E); throw(E); } }, -- 2.11.0