]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/rados: add ConnectionShutdown exception class
authorRamana Raja <rraja@redhat.com>
Thu, 12 Jan 2023 02:53:16 +0000 (21:53 -0500)
committerRamana Raja <rraja@redhat.com>
Tue, 8 Aug 2023 20:26:07 +0000 (16:26 -0400)
Signed-off-by: Ramana Raja <rraja@redhat.com>
(cherry picked from commit e452899013323def87a8b9e6edbdae66067a827c)

src/pybind/rados/rados.pyx

index 67d8a1e2c7e35f38df1817d69515b063cc686576..06c4a3547303f5461790400a86b4a9437f15c396 100644 (file)
@@ -224,6 +224,13 @@ class IsConnected(Error):
                 "RADOS is connected error (%s)" % message, errno)
 
 
+class ConnectionShutdown(OSError):
+    """ `ConnectionShutdown` class, derived from `OSError` """
+    def __init__(self, message, errno=None):
+        super(ConnectionShutdown, self).__init__(
+                "RADOS connection was shutdown (%s)" % message, errno)
+
+
 IF UNAME_SYSNAME == "FreeBSD":
     cdef errno_to_exception = {
         errno.EPERM     : PermissionError,
@@ -240,6 +247,7 @@ IF UNAME_SYSNAME == "FreeBSD":
         errno.EISCONN   : IsConnected,
         errno.EINVAL    : InvalidArgumentError,
         errno.ENOTCONN  : NotConnected,
+        errno.ESHUTDOWN : ConnectionShutdown,
     }
 ELSE:
     cdef errno_to_exception = {
@@ -257,6 +265,7 @@ ELSE:
         errno.EISCONN   : IsConnected,
         errno.EINVAL    : InvalidArgumentError,
         errno.ENOTCONN  : NotConnected,
+        errno.ESHUTDOWN : ConnectionShutdown,
     }