summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-03-09 20:38:33 +0900
committerbst-marge-bot <marge-bot@buildstream.build>2019-03-12 07:14:58 +0000
commitbb44f093f6169aee5db41a7e4523affff12ed412 (patch)
tree7a57a13d91b3ae3af06d9a8d9cfc714ebb342830
parente202f90366a8bb7fc10afc1c3428fdc91463bdfb (diff)
downloadbuildstream-bb44f093f6169aee5db41a7e4523affff12ed412.tar.gz
_loader/loader.py: Specify junction name in missing file errors where appropriate
When a file is missing in a subproject, it is not particularly meaningful to specify the filesystem path to the elements directory of the subproject, as this temporary staging directory belongs to BuildStream and not the user. Instead, when a file is missing in a subproject, specifying the junction name is more useful. This fixes an aspect of #947
-rw-r--r--buildstream/_loader/loader.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/buildstream/_loader/loader.py b/buildstream/_loader/loader.py
index 84b0a17d8..1607c5b5e 100644
--- a/buildstream/_loader/loader.py
+++ b/buildstream/_loader/loader.py
@@ -209,19 +209,28 @@ class Loader():
project=self.project, yaml_cache=yaml_cache)
except LoadError as e:
if e.reason == LoadErrorReason.MISSING_FILE:
+
+ if self.project.junction:
+ message = "Could not find element '{}' in project referred to by junction element '{}'" \
+ .format(filename, self.project.junction.name)
+ else:
+ message = "Could not find element '{}' in elements directory '{}'".format(filename, self._basedir)
+
+ if provenance:
+ message = "{}: {}".format(provenance, message)
+
# If we can't find the file, try to suggest plausible
# alternatives by stripping the element-path from the given
# filename, and verifying that it exists.
- message = "Could not find element '{}' in elements directory '{}'".format(filename, self._basedir)
- if provenance:
- message = "{}: {}".format(provenance, message)
detail = None
elements_dir = os.path.relpath(self._basedir, self.project.directory)
element_relpath = os.path.relpath(filename, elements_dir)
if filename.startswith(elements_dir) and os.path.exists(os.path.join(self._basedir, element_relpath)):
detail = "Did you mean '{}'?".format(element_relpath)
+
raise LoadError(LoadErrorReason.MISSING_FILE,
message, detail=detail) from e
+
elif e.reason == LoadErrorReason.LOADING_DIRECTORY:
# If a <directory>.bst file exists in the element path,
# let's suggest this as a plausible alternative.