summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2014-08-03 12:16:00 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2014-08-04 07:54:05 -0700
commitcabfc374eb0fe546ea8377eb64f4415bbd11e3f8 (patch)
tree347787878e854dc7154b53885bd80a98857cd07d /lib
parent3779c78c009fb7465bac25b4e59b5f710e3bd0da (diff)
downloadspack-cabfc374eb0fe546ea8377eb64f4415bbd11e3f8.tar.gz
spack-cabfc374eb0fe546ea8377eb64f4415bbd11e3f8.tar.bz2
spack-cabfc374eb0fe546ea8377eb64f4415bbd11e3f8.tar.xz
spack-cabfc374eb0fe546ea8377eb64f4415bbd11e3f8.zip
More descriptive error when package constructor fails.
- helps package_sanity test identify which package failed. - encountered while upgrading versions in Adam's packages to the new format.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/packages.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/spack/spack/packages.py b/lib/spack/spack/packages.py
index 00834c95d5..4f9f606c89 100644
--- a/lib/spack/spack/packages.py
+++ b/lib/spack/spack/packages.py
@@ -69,7 +69,10 @@ class PackageDB(object):
if not spec in self.instances:
package_class = self.get_class_for_package_name(spec.name)
- self.instances[spec.name] = package_class(spec)
+ try:
+ self.instances[spec.name] = package_class(spec)
+ except Exception, e:
+ raise FailedConstructorError(spec.name, e)
return self.instances[spec.name]
@@ -227,3 +230,12 @@ class UnknownPackageError(spack.error.SpackError):
def __init__(self, name):
super(UnknownPackageError, self).__init__("Package %s not found." % name)
self.name = name
+
+
+class FailedConstructorError(spack.error.SpackError):
+ """Raised when a package's class constructor fails."""
+ def __init__(self, name, reason):
+ super(FailedConstructorError, self).__init__(
+ "Class constructor failed for package '%s'." % name,
+ str(reason))
+ self.name = name