diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2019-03-09 20:38:33 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2019-03-09 21:02:40 +0900 |
commit | d23aa49a419bc6c79a39f361cbfc3f69f50c7be5 (patch) | |
tree | 1baca1ed69d735f16a40919d2e64e9b0dd916408 | |
parent | 508ad1cb83b08026f4f5524d6a28e4130a4a9ff1 (diff) | |
download | buildstream-d23aa49a419bc6c79a39f361cbfc3f69f50c7be5.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.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/buildstream/_loader/loader.py b/buildstream/_loader/loader.py index b2f98ea06..eec60b193 100644 --- a/buildstream/_loader/loader.py +++ b/buildstream/_loader/loader.py @@ -223,19 +223,28 @@ class Loader(): node = _yaml.load(fullpath, shortname=filename, copy_tree=rewritable, project=self.project) 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. |