diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2016-04-27 12:28:03 +0000 |
---|---|---|
committer | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2016-04-27 13:32:30 +0000 |
commit | e5980ebf622e99925bc65f60634537c0951b48ca (patch) | |
tree | 918df60a55ef7f0f90cc61c3513ecb6dfbfbd2ce | |
parent | 3158e9b562e9b8ae41aaf5f90a4fb064cd87e66d (diff) | |
download | morph-e5980ebf622e99925bc65f60634537c0951b48ca.tar.gz |
build: Give a helpful error when the file to be built is not found
Recently something regressed which meant that when building a missing
file, the result was this long unhelpful traceback:
2016-04-27 12:23:36 Deciding on task order
Traceback (most recent call last):
...
File "/src/morph/morphlib/sourceresolver.py", line 506, in create_source_pool
definitions_original_ref=original_ref)
File "/src/morph/morphlib/sourceresolver.py", line 440, in add_morphs_to_source_pool
add_to_pool, predefined_split_rules)
File "/src/morph/morphlib/sourceresolver.py", line 287, in _process_definitions_with_children
morphology = get_morphology(filename)
File "/src/morph/morphlib/sourceresolver.py", line 282, in get_morphology
filename)
File "/src/morph/morphlib/sourceresolver.py", line 255, in _get_morphology
morph = morph_loader.load_from_string(text, filename)
File "/src/morph/morphlib/morphloader.py", line 395, in load_from_string
obj = yaml.safe_load(string)
...
File "/usr/lib/python2.7/site-packages/yaml/reader.py", line 178, in update_raw
data = self.stream.read(size)
AttributeError: 'NoneType' object has no attribute 'read'
Now the error is:
ERROR: Couldn't find definition file to build: missing-file.morph
Change-Id: Iabb315c9d0ac5c7c50003db36a1b21e86fb23223
-rw-r--r-- | morphlib/sourceresolver.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/morphlib/sourceresolver.py b/morphlib/sourceresolver.py index 5af789c0..872a8216 100644 --- a/morphlib/sourceresolver.py +++ b/morphlib/sourceresolver.py @@ -96,7 +96,7 @@ class SourceResolverError(cliapp.AppException): class MorphologyNotFoundError(SourceResolverError): def __init__(self, filename): SourceResolverError.__init__( - self, "Couldn't find morphology: %s" % filename) + self, "Couldn't find definition file to build: %s" % filename) class MorphologyReferenceNotFoundError(SourceResolverError): @@ -252,9 +252,11 @@ class SourceResolver(object): text = self._get_file_contents_from_definitions( definitions_checkout_dir, filename) - morph = morph_loader.load_from_string(text, filename) - if morph is not None: + if text is None: + morph = None + else: + morph = morph_loader.load_from_string(text, filename) resolved_morphologies[filename] = morph return morph |