summaryrefslogtreecommitdiff
path: root/buildstream/sandbox
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-11-06 17:40:34 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-11-06 17:40:34 +0900
commit0defb35c0334d78e48bcf21ec6b106b67761e1bc (patch)
treea1e737218ea08dd899586500fb2586db8b47b56d /buildstream/sandbox
parent66eeac0d81ec3d109ff6175e8190e08c4659b561 (diff)
downloadbuildstream-0defb35c0334d78e48bcf21ec6b106b67761e1bc.tar.gz
Refactoring: Move ElementError and SourceError to their respective classes, create SandboxError
These errors are a part of public facing API, and the exceptions module contains a lot of internal details to be hidden from public API. This move required creating SandboxError because sandbox related code had previously been hijacking the ElementError and raising that.
Diffstat (limited to 'buildstream/sandbox')
-rw-r--r--buildstream/sandbox/_mount.py6
-rw-r--r--buildstream/sandbox/_sandboxchroot.py12
2 files changed, 9 insertions, 9 deletions
diff --git a/buildstream/sandbox/_mount.py b/buildstream/sandbox/_mount.py
index 9b2c4cc1d..472534c9e 100644
--- a/buildstream/sandbox/_mount.py
+++ b/buildstream/sandbox/_mount.py
@@ -1,7 +1,7 @@
import sys
from contextlib import contextmanager
-from .. import ElementError
+from .. import SandboxError
from .. import utils, _signals
@@ -32,7 +32,7 @@ class Mount(object):
)
if status != 0:
- raise ElementError('`{}` failed with exit code {}'
+ raise SandboxError('`{}` failed with exit code {}'
.format(' '.join(argv), status))
return dest
@@ -49,7 +49,7 @@ class Mount(object):
)
if status != 0:
- raise ElementError('`{}` failed with exit code {}'
+ raise SandboxError('`{}` failed with exit code {}'
.format(' '.join(cmd), status))
# mount()
diff --git a/buildstream/sandbox/_sandboxchroot.py b/buildstream/sandbox/_sandboxchroot.py
index de3220c22..b1c5997fa 100644
--- a/buildstream/sandbox/_sandboxchroot.py
+++ b/buildstream/sandbox/_sandboxchroot.py
@@ -27,7 +27,7 @@ import signal
import subprocess
from contextlib import contextmanager, ExitStack
-from .. import ElementError
+from .. import SandboxError
from .. import utils
from .. import _signals
from ._mount import Mount
@@ -184,11 +184,11 @@ class SandboxChroot(Sandbox):
# 'Exception occurred in preexec_fn', turn these into
# a more readable message.
if '{}'.format(e) == 'Exception occurred in preexec_fn.':
- raise ElementError('Could not chroot into {} or chdir into {}. '
+ raise SandboxError('Could not chroot into {} or chdir into {}. '
'Ensure you are root and that the relevant directory exists.'
.format(rootfs, cwd)) from e
else:
- raise ElementError('Could not run command {}: {}'.format(command, e)) from e
+ raise SandboxError('Could not run command {}: {}'.format(command, e)) from e
return code
@@ -219,7 +219,7 @@ class SandboxChroot(Sandbox):
devices.append(self.mknod(device, location))
except OSError as err:
if err.errno == 1:
- raise ElementError("Permission denied while creating device node: {}.".format(err) +
+ raise SandboxError("Permission denied while creating device node: {}.".format(err) +
"BuildStream reqiures root permissions for these setttings.")
else:
raise
@@ -307,10 +307,10 @@ class SandboxChroot(Sandbox):
os.mknod(target, mode=stat.S_IFCHR | dev.st_mode, device=target_dev)
except PermissionError as e:
- raise ElementError('Could not create device {}, ensure that you have root permissions: {}')
+ raise SandboxError('Could not create device {}, ensure that you have root permissions: {}')
except OSError as e:
- raise ElementError('Could not create device {}: {}'
+ raise SandboxError('Could not create device {}: {}'
.format(target, e)) from e
return target