Better error messages for spack reindex
.
This commit is contained in:
parent
c898b9db04
commit
cdc2ebee90
2 changed files with 17 additions and 7 deletions
|
@ -646,6 +646,7 @@ def __init__(self, path, msg=''):
|
|||
class InvalidDatabaseVersionError(SpackError):
|
||||
def __init__(self, expected, found):
|
||||
super(InvalidDatabaseVersionError, self).__init__(
|
||||
"Expected database version %s but found version %s." + \
|
||||
"Try running `spack reindex` to fix." %
|
||||
(expected, found))
|
||||
"Expected database version %s but found version %s."
|
||||
% (expected, found),
|
||||
"`spack reindex` may fix this, or you may need a newer "
|
||||
"Spack version.")
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
import llnl.util.tty as tty
|
||||
from llnl.util.filesystem import join_path, mkdirp
|
||||
|
||||
import spack
|
||||
from spack.spec import Spec
|
||||
from spack.error import SpackError
|
||||
|
||||
|
@ -223,8 +224,14 @@ def write_spec(self, spec, path):
|
|||
|
||||
def read_spec(self, path):
|
||||
"""Read the contents of a file and parse them as a spec"""
|
||||
with open(path) as f:
|
||||
spec = Spec.from_yaml(f)
|
||||
try:
|
||||
with open(path) as f:
|
||||
spec = Spec.from_yaml(f)
|
||||
except Exception as e:
|
||||
if spack.debug:
|
||||
raise
|
||||
raise SpecReadError(
|
||||
'Unable to read file: %s' % path, 'Cause: ' + str(e))
|
||||
|
||||
# Specs read from actual installations are always concrete
|
||||
spec._mark_concrete()
|
||||
|
@ -456,10 +463,12 @@ def __init__(self, path):
|
|||
"Install path %s already exists!")
|
||||
|
||||
|
||||
class SpecReadError(DirectoryLayoutError):
|
||||
"""Raised when directory layout can't read a spec."""
|
||||
|
||||
|
||||
class InvalidExtensionSpecError(DirectoryLayoutError):
|
||||
"""Raised when an extension file has a bad spec in it."""
|
||||
def __init__(self, message):
|
||||
super(InvalidExtensionSpecError, self).__init__(message)
|
||||
|
||||
|
||||
class ExtensionAlreadyInstalledError(DirectoryLayoutError):
|
||||
|
|
Loading…
Reference in a new issue