Bug 1456051 - Propagate OS errors on addon installation. r?maja_zf draft
authorAndreas Tolfsen <ato@sny.no>
Mon, 23 Apr 2018 07:48:54 +0100
changeset 786519 5aaea9dc6e67eca74339261acd2a06f352e2b8b2
parent 786518 5e83a6f189527705101ff73387f5e892ecd90a2d
child 786520 dde46c4dfec5cb17059d07006bb3ea2f1bcecd9f
push id107501
push userbmo:ato@sny.no
push dateMon, 23 Apr 2018 14:06:07 +0000
reviewersmaja_zf
bugs1456051
milestone61.0a1
Bug 1456051 - Propagate OS errors on addon installation. r?maja_zf The error descriptions are rather vague and may obfuscate the real problem. This changes the messages to be more in line with the underlying error, and also ensures the original error is propagated. MozReview-Commit-ID: EjctkgeUgNH
testing/marionette/addon.js
testing/marionette/harness/marionette_harness/tests/unit/test_addons.py
--- a/testing/marionette/addon.js
+++ b/testing/marionette/addon.js
@@ -82,32 +82,32 @@ async function installAddon(file) {
  */
 addon.install = async function(path, temporary = false) {
   let addon;
   let file;
 
   try {
     file = new FileUtils.File(path);
   } catch (e) {
-    throw new UnknownError(`${path} is not an absolute path.`);
+    throw new UnknownError(`Expected absolute path: ${e}`, e);
   }
 
   if (!file.exists()) {
-    throw new UnknownError(`Could not find add-on at '${path}'`);
+    throw new UnknownError(`No such file or directory: ${path}`);
   }
 
   try {
     if (temporary) {
       addon = await AddonManager.installTemporaryAddon(file);
     } else {
       addon = await installAddon(file);
     }
   } catch (e) {
     throw new UnknownError(
-        `Could not install add-on at '${path}': ${e.message}`);
+        `Could not install add-on: ${path}: ${e.message}`, e);
   }
 
   return addon.id;
 };
 
 /**
  * Uninstall a Firefox addon.
  *
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_addons.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_addons.py
@@ -91,14 +91,14 @@ class TestAddons(MarionetteTestCase):
         addon_path = os.path.join(here, "webextension-unsigned.xpi")
 
         with self.assertRaises(AddonInstallException):
             self.addons.install(addon_path)
 
     def test_install_nonexistent_addon(self):
         addon_path = os.path.join(here, "does-not-exist.xpi")
 
-        with self.assertRaisesRegexp(AddonInstallException, "Could not find add-on at"):
+        with self.assertRaises(AddonInstallException):
             self.addons.install(addon_path)
 
     def test_install_with_relative_path(self):
-        with self.assertRaisesRegexp(AddonInstallException, "is not an absolute path."):
+        with self.assertRaises(AddonInstallException):
             self.addons.install('webextension.xpi')