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

--HG--
extra : rebase_source : be10efb18f581d4643e5f52a982b888a72ef27be
This commit is contained in:
Andreas Tolfsen 2018-04-23 07:48:54 +01:00
parent 6fcd3c1caa
commit f3f07d1533
2 changed files with 5 additions and 5 deletions

View File

@ -87,11 +87,11 @@ addon.install = async function(path, temporary = false) {
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 {
@ -102,7 +102,7 @@ addon.install = async function(path, temporary = false) {
}
} 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;

View File

@ -96,9 +96,9 @@ class TestAddons(MarionetteTestCase):
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')