summaryrefslogtreecommitdiff
path: root/src/buildstream/_workspaces.py
diff options
context:
space:
mode:
authorTom Pollard <tom.pollard@codethink.co.uk>2019-07-17 15:48:06 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-07-18 11:36:07 +0000
commite7524c4340523d06ba3d6d95cb1e284b0f4b415e (patch)
tree271d658e2fcdb7917dfca3c1270a4c3f31e80d76 /src/buildstream/_workspaces.py
parentd79747d7ee2596a73f4ec68bd40bd2ca04427a93 (diff)
downloadbuildstream-e7524c4340523d06ba3d6d95cb1e284b0f4b415e.tar.gz
_exceptions.py: Align LoadError() parameter orderingtpollard/loaderror
All of the errors which subclass from BstError have their first positional argument as message, LoadError should follow this ordering for consistency.
Diffstat (limited to 'src/buildstream/_workspaces.py')
-rw-r--r--src/buildstream/_workspaces.py25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/buildstream/_workspaces.py b/src/buildstream/_workspaces.py
index 2cda5a215..aa507bd63 100644
--- a/src/buildstream/_workspaces.py
+++ b/src/buildstream/_workspaces.py
@@ -216,8 +216,8 @@ class WorkspaceProjectCache():
def remove(self, directory):
workspace_project = self.get(directory)
if not workspace_project:
- raise LoadError(LoadErrorReason.MISSING_FILE,
- "Failed to find a {} file to remove".format(WORKSPACE_PROJECT_FILE))
+ raise LoadError("Failed to find a {} file to remove".format(WORKSPACE_PROJECT_FILE),
+ LoadErrorReason.MISSING_FILE)
path = workspace_project.get_filename()
try:
os.unlink(path)
@@ -363,8 +363,8 @@ class Workspace():
try:
stat = os.lstat(filename)
except OSError as e:
- raise LoadError(LoadErrorReason.MISSING_FILE,
- "Failed to stat file in workspace: {}".format(e))
+ raise LoadError("Failed to stat file in workspace: {}".format(e),
+ LoadErrorReason.MISSING_FILE)
# Use the mtime of any file with sub second precision
return stat.st_mtime_ns
@@ -574,8 +574,8 @@ class Workspaces():
try:
version = workspaces.get_int('format-version', default=0)
except ValueError:
- raise LoadError(LoadErrorReason.INVALID_DATA,
- "Format version is not an integer in workspace configuration")
+ raise LoadError("Format version is not an integer in workspace configuration",
+ LoadErrorReason.INVALID_DATA)
if version == 0:
# Pre-versioning format can be of two forms
@@ -591,14 +591,14 @@ class Workspaces():
detail = "There are multiple workspaces open for '{}'.\n" + \
"This is not supported anymore.\n" + \
"Please remove this element from '{}'."
- raise LoadError(LoadErrorReason.INVALID_DATA,
- detail.format(element, self._get_filename()))
+ raise LoadError(detail.format(element, self._get_filename()),
+ LoadErrorReason.INVALID_DATA)
workspaces[element] = sources[0]
else:
- raise LoadError(LoadErrorReason.INVALID_DATA,
- "Workspace config is in unexpected format.")
+ raise LoadError("Workspace config is in unexpected format.",
+ LoadErrorReason.INVALID_DATA)
res = {
element: Workspace(self._toplevel_project, path=config.as_str())
@@ -611,10 +611,9 @@ class Workspaces():
for element, node in workspaces.items()}
else:
- raise LoadError(LoadErrorReason.INVALID_DATA,
- "Workspace configuration format version {} not supported."
+ raise LoadError("Workspace configuration format version {} not supported."
"Your version of buildstream may be too old. Max supported version: {}"
- .format(version, BST_WORKSPACE_FORMAT_VERSION))
+ .format(version, BST_WORKSPACE_FORMAT_VERSION), LoadErrorReason.INVALID_DATA)
return res