diff options
author | Tristan van Berkom <tristan@codethink.co.uk> | 2020-12-09 16:04:56 +0900 |
---|---|---|
committer | Tristan van Berkom <tristan@codethink.co.uk> | 2020-12-21 14:46:14 +0900 |
commit | 95c3330af22b33c51157e7e02770d2cc58ab3e6a (patch) | |
tree | a0ea5b6c1bd50a006a2628da2de6d992ab674fba /src | |
parent | 598741803aa0dcf911cd3bd5dbb267b599ab185f (diff) | |
download | buildstream-95c3330af22b33c51157e7e02770d2cc58ab3e6a.tar.gz |
_stream.py: Added missing machine readable error codes
In errors pertaining to failing to launch a shell with a buildtree.
Other related updates:
- _frontend/cli.py: Propagate machine readable error codes in `bst shell`
This command prefixes a reported error, so it rewraps the error into
an AppError, this needs to propagate the originating machine readable
error.
- tests/integration/shell.py, tests/integration/shellbuildtrees.py:
Updated to use new machine readable errors
Diffstat (limited to 'src')
-rw-r--r-- | src/buildstream/_frontend/cli.py | 2 | ||||
-rw-r--r-- | src/buildstream/_stream.py | 6 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py index 5e42bda68..ab06e8a8a 100644 --- a/src/buildstream/_frontend/cli.py +++ b/src/buildstream/_frontend/cli.py @@ -640,7 +640,7 @@ def shell(app, element, mount, isolate, build_, cli_buildtree, pull_, command): pull_=pull_, ) except BstError as e: - raise AppError("Error launching shell: {}".format(e), detail=e.detail) from e + raise AppError("Error launching shell: {}".format(e), detail=e.detail, reason=e.reason) from e # If there were no errors, we return the shell's exit code here. sys.exit(exitcode) diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py index 0aff5fb94..e91ee882c 100644 --- a/src/buildstream/_stream.py +++ b/src/buildstream/_stream.py @@ -221,6 +221,7 @@ class Stream: raise StreamError( "Elements need to be built or downloaded before staging a shell environment", detail="\n".join(list(map(lambda x: x._get_full_name(), missing_deps))), + reason="shell-missing-deps", ) # Check if we require a pull queue attempt, with given artifact state and context @@ -229,11 +230,14 @@ class Stream: remotes_message = " or in available remotes" if pull_ else "" if not element._cached(): message = "Artifact not cached locally" + remotes_message + reason = "missing-buildtree-artifact-not-cached" elif element._buildtree_exists(): message = "Buildtree is not cached locally" + remotes_message + reason = "missing-buildtree-artifact-buildtree-not-cached" else: message = "Artifact was created without buildtree" - raise StreamError(message) + reason = "missing-buildtree-artifact-created-without-buildtree" + raise StreamError(message, reason=reason) # Raise warning if the element is cached in a failed state if element._cached_failure(): |