summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Maw <jonathan.maw@codethink.co.uk>2018-01-10 17:36:17 +0000
committerJonathan Maw <jonathan.maw@codethink.co.uk>2018-01-25 13:27:40 +0000
commit9bf5278a154329befb176cd067a5cf7d2a996575 (patch)
tree2591802179968e7bec7329b25445917407b63925
parent2aa233da274ef3ad6bc2f7f832d2df43d71a1eec (diff)
downloadbuildstream-9bf5278a154329befb176cd067a5cf7d2a996575.tar.gz
Add explicit error handling for ElementErrors that happen as a result of staging artifacts
-rw-r--r--buildstream/_frontend/main.py5
-rw-r--r--buildstream/_pipeline.py28
2 files changed, 20 insertions, 13 deletions
diff --git a/buildstream/_frontend/main.py b/buildstream/_frontend/main.py
index e62202013..5944a49ac 100644
--- a/buildstream/_frontend/main.py
+++ b/buildstream/_frontend/main.py
@@ -1014,7 +1014,10 @@ class App():
#
if choice == 'shell':
click.echo("\nDropping into an interactive shell in the failed build sandbox\n", err=True)
- element._shell(Scope.BUILD, failure.sandbox)
+ try:
+ element._shell(Scope.BUILD, failure.sandbox)
+ except BstError as e:
+ click.echo("Error while attempting to create interactive shell: {}".format(e), err=True)
elif choice == 'log':
with open(failure.logfile, 'r') as logfile:
content = logfile.read()
diff --git a/buildstream/_pipeline.py b/buildstream/_pipeline.py
index 551861e7c..5894bdaed 100644
--- a/buildstream/_pipeline.py
+++ b/buildstream/_pipeline.py
@@ -516,18 +516,22 @@ class Pipeline():
.format(directory))
# Stage deps into a temporary sandbox first
- with target._prepare_sandbox(Scope.RUN, None, integrate=integrate) as sandbox:
-
- # Copy or move the sandbox to the target directory
- sandbox_root = sandbox.get_directory()
- with target.timed_activity("Checking out files in {}".format(directory)):
- try:
- if hardlinks:
- self.checkout_hardlinks(sandbox_root, directory)
- else:
- utils.copy_files(sandbox_root, directory)
- except OSError as e:
- raise PipelineError("Failed to checkout files: {}".format(e)) from e
+ try:
+ with target._prepare_sandbox(Scope.RUN, None, integrate=integrate) as sandbox:
+
+ # Copy or move the sandbox to the target directory
+ sandbox_root = sandbox.get_directory()
+ with target.timed_activity("Checking out files in {}".format(directory)):
+ try:
+ if hardlinks:
+ self.checkout_hardlinks(sandbox_root, directory)
+ else:
+ utils.copy_files(sandbox_root, directory)
+ except OSError as e:
+ raise PipelineError("Failed to checkout files: {}".format(e)) from e
+ except BstError as e:
+ raise PipelineError("Error while staging dependencies into a sandbox: {}".format(e),
+ reason=e.reason) from e
# Helper function for checkout()
#