summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-01-02 16:58:41 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-01-02 17:01:41 +0900
commit8b60c55e83af9204ebb784d7dfd30543576f4692 (patch)
treec04e4bcae0128e199be6e7957678028adb45af8a
parent54265b7a9e6f493796bcb9c65682a73013e2a600 (diff)
downloadbuildstream-8b60c55e83af9204ebb784d7dfd30543576f4692.tar.gz
source.py: Raise proper SourceError() when failing to create the staging directory
This changes the UX to report a better human readable error, which is otherwise a BUG message with stack trace.
-rw-r--r--buildstream/source.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/buildstream/source.py b/buildstream/source.py
index 63d8ffafd..bfea143ae 100644
--- a/buildstream/source.py
+++ b/buildstream/source.py
@@ -306,7 +306,13 @@ class Source(Plugin):
def _ensure_directory(self, directory):
if self.__directory is not None:
directory = os.path.join(directory, self.__directory.lstrip(os.sep))
- os.makedirs(directory, exist_ok=True)
+
+ try:
+ os.makedirs(directory, exist_ok=True)
+ except OSError as e:
+ raise SourceError("Failed to create staging directory: {}"
+ .format(e),
+ reason="ensure-stage-dir-fail") from e
return directory
# Wrapper for stage() api which gives the source