diff options
author | Angelos Evripiotis <jevripiotis@bloomberg.net> | 2018-10-23 09:31:16 +0100 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2019-02-11 09:24:48 +0000 |
commit | 02e48209ec7af316afc8390dcb14d1135115878b (patch) | |
tree | c7d18edbc45b76dcdc86c7a8c86c57bf40c3eb96 /buildstream/_includes.py | |
parent | 1ed63e542797f5097a1c9a1952fd50e435e1783a (diff) | |
download | buildstream-02e48209ec7af316afc8390dcb14d1135115878b.tar.gz |
_includes: better error on missing include
Previously, a missing include would result in an error like this:
Could not find file at not-a-file.include
Note that the file containing the include was not mentioned.
Now we get an error like this instead:
element.bst [line 7 column 5]: Include block references a file that
could not be found: 'not-a-file.include'.
Diffstat (limited to 'buildstream/_includes.py')
-rw-r--r-- | buildstream/_includes.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/buildstream/_includes.py b/buildstream/_includes.py index d27f901a0..cb7faa4de 100644 --- a/buildstream/_includes.py +++ b/buildstream/_includes.py @@ -50,8 +50,17 @@ class Includes: for include in reversed(includes): if only_local and ':' in include: continue - include_node, file_path, sub_loader = self._include_file(include, - current_loader) + try: + include_node, file_path, sub_loader = self._include_file(include, + current_loader) + except LoadError as e: + if e.reason == LoadErrorReason.MISSING_FILE: + message = "{}: Include block references a file that could not be found: '{}'.".format( + include_provenance, include) + raise LoadError(LoadErrorReason.MISSING_FILE, message) from e + else: + raise + if file_path in included: raise LoadError(LoadErrorReason.RECURSIVE_INCLUDE, "{}: trying to recursively include {}". format(include_provenance, |