From 95c3330af22b33c51157e7e02770d2cc58ab3e6a Mon Sep 17 00:00:00 2001 From: Tristan van Berkom Date: Wed, 9 Dec 2020 16:04:56 +0900 Subject: _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 --- src/buildstream/_frontend/cli.py | 2 +- src/buildstream/_stream.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src') 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(): -- cgit v1.2.1