summaryrefslogtreecommitdiff
path: root/src/pybind/cephfs.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/pybind/cephfs.py')
-rw-r--r--src/pybind/cephfs.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/pybind/cephfs.py b/src/pybind/cephfs.py
index 443c7334f9d..6a769b2a8aa 100644
--- a/src/pybind/cephfs.py
+++ b/src/pybind/cephfs.py
@@ -45,19 +45,17 @@ def make_ex(ret, msg):
:returns: a subclass of :class:`Error`
"""
+ errors = {
+ errno.EPERM : PermissionError,
+ errno.ENOENT : ObjectNotFound,
+ errno.EIO : IOError,
+ errno.ENOSPC : NoSpace,
+ errno.EEXIST : ObjectExists,
+ errno.ENODATA : NoData
+ }
ret = abs(ret)
- if ret == errno.EPERM:
- return PermissionError(msg)
- elif ret == errno.ENOENT:
- return ObjectNotFound(msg)
- elif ret == errno.EIO:
- return IOError(msg)
- elif ret == errno.ENOSPC:
- return NoSpace(msg)
- elif ret == errno.EEXIST:
- return ObjectExists(msg)
- elif ret == errno.ENODATA:
- return NoData(msg)
+ if ret in errors:
+ return errors[ret](msg)
else:
return Error(msg + (": error code %d" % ret))