Bug 1072244 - Correctly throw the exceptions in TPS framework. r=hskupin a=testonly DONTBUILD
authorCosmin Malutan <cosmin.malutan@softvision.ro>
Mon, 13 Oct 2014 14:25:04 -0700
changeset 225795 48e3c2f927d5
parent 225794 3e2c92836231
child 225796 8cf65ccdce3d
push id4020
push userhskupin@mozilla.com
push date2014-10-24 11:07 +0000
treeherdermozilla-beta@48e3c2f927d5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershskupin, testonly
bugs1072244
milestone34.0
Bug 1072244 - Correctly throw the exceptions in TPS framework. r=hskupin a=testonly DONTBUILD
services/sync/tps/extensions/tps/components/tps-cmdline.js
services/sync/tps/extensions/tps/resource/logger.jsm
services/sync/tps/extensions/tps/resource/modules/addons.jsm
services/sync/tps/extensions/tps/resource/modules/bookmarks.jsm
services/sync/tps/extensions/tps/resource/quit.js
--- a/services/sync/tps/extensions/tps/components/tps-cmdline.js
+++ b/services/sync/tps/extensions/tps/components/tps-cmdline.js
@@ -77,17 +77,17 @@ TPSCmdLineHandler.prototype = {
              "  -tpslogfile <file>        Logfile for TPS output.\n" +
              "  --ignore-unused-engines   Don't load engines not used in tests.\n",
 };
 
 
 var TPSCmdLineFactory = {
   createInstance : function(outer, iid) {
     if (outer != null) {
-      throw Components.results.NS_ERROR_NO_AGGREGATION;
+      throw new Error(Components.results.NS_ERROR_NO_AGGREGATION);
     }
 
     return new TPSCmdLineHandler().QueryInterface(iid);
   }
 };
 
 
 var TPSCmdLineModule = {
@@ -122,20 +122,20 @@ var TPSCmdLineModule = {
   },
 
   getClassObject : function(compMgr, cid, iid) {
     if (cid.equals(TPS_CMDLINE_CLSID)) {
       return TPSCmdLineFactory;
     }
 
     if (!iid.equals(Components.interfaces.nsIFactory)) {
-      throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
+      throw new Error(Components.results.NS_ERROR_NOT_IMPLEMENTED);
     }
 
-    throw Components.results.NS_ERROR_NO_INTERFACE;
+    throw new Error(Components.results.NS_ERROR_NO_INTERFACE);
   },
 
   canUnload : function(compMgr) {
     return true;
   }
 };
 
 /**
--- a/services/sync/tps/extensions/tps/resource/logger.jsm
+++ b/services/sync/tps/extensions/tps/resource/logger.jsm
@@ -69,26 +69,26 @@ var Logger = {
     if (bool) {
       return;
     }
 
     if (showPotentialError && this._potentialError) {
       msg += "; " + this._potentialError;
       this._potentialError = null;
     }
-    throw("ASSERTION FAILED! " + msg);
+    throw new Error("ASSERTION FAILED! " + msg);
   },
 
   AssertFalse: function(bool, msg, showPotentialError) {
     return this.AssertTrue(!bool, msg, showPotentialError);
   },
 
   AssertEqual: function(val1, val2, msg) {
     if (val1 != val2)
-      throw("ASSERTION FAILED! " + msg + "; expected " +
+      throw new Error("ASSERTION FAILED! " + msg + "; expected " +
             JSON.stringify(val2) + ", got " + JSON.stringify(val1));
   },
 
   log: function (msg, withoutPrefix) {
     dump(msg + "\n");
     if (withoutPrefix) {
       this.write(msg + "\n");
     }
--- a/services/sync/tps/extensions/tps/resource/modules/addons.jsm
+++ b/services/sync/tps/extensions/tps/resource/modules/addons.jsm
@@ -78,17 +78,17 @@ Addon.prototype = {
                    !addon.userDisabled);
     if (state == STATE_ENABLED) {
       Logger.AssertFalse(addon.userDisabled, "add-on is disabled: " + addon.id);
       return true;
     } else if (state == STATE_DISABLED) {
       Logger.AssertTrue(addon.userDisabled, "add-on is enabled: " + addon.id);
       return true;
     } else if (state) {
-      throw Error("Don't know how to handle state: " + state);
+      throw new Error("Don't know how to handle state: " + state);
     } else {
       // No state, so just checking that it exists.
       return true;
     }
   },
 
   install: function install() {
     // For Install, the id parameter initially passed is really the filename
--- a/services/sync/tps/extensions/tps/resource/modules/bookmarks.jsm
+++ b/services/sync/tps/extensions/tps/resource/modules/bookmarks.jsm
@@ -771,17 +771,17 @@ Livemark.prototype = {
 
     PlacesUtils.livemarks.addLivemark(livemarkObj).then(
       aLivemark => { spinningCb(null, [Components.results.NS_OK, aLivemark]) },
       () => { spinningCb(null, [Components.results.NS_ERROR_UNEXPECTED, aLivemark]) }
     );
 
     let [status, livemark] = spinningCb.wait();
     if (!Components.isSuccessCode(status)) {
-      throw status;
+      throw new Error(status);
     }
 
     this.props.item_id = livemark.id;
     return this.props.item_id;
   },
 
   /**
    * Find
--- a/services/sync/tps/extensions/tps/resource/quit.js
+++ b/services/sync/tps/extensions/tps/resource/quit.js
@@ -43,21 +43,21 @@ function goQuitApplication() {
     forceQuit  = Components.interfaces.nsIAppStartup.eForceQuit;
   }
   else if (kAppShell in Components.classes) {
     appService = Components.classes[kAppShell].
       getService(Components.interfaces.nsIAppShellService);
     forceQuit = Components.interfaces.nsIAppShellService.eForceQuit;
   }
   else {
-    throw 'goQuitApplication: no AppStartup/appShell';
+    throw new Error('goQuitApplication: no AppStartup/appShell');
   }
 
   try {
     appService.quit(forceQuit);
   }
   catch(ex) {
-    throw('goQuitApplication: ' + ex);
+    throw new Error('goQuitApplication: ' + ex);
   }
 
   return true;
 }