]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/cephfs: add method to get error code in Error and OSError
authorRishabh Dave <ridave@redhat.com>
Fri, 13 Dec 2019 06:47:27 +0000 (12:17 +0530)
committerRishabh Dave <ridave@redhat.com>
Thu, 9 Jan 2020 11:03:32 +0000 (16:33 +0530)
Add method to class Error and override it class OSError.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
src/pybind/cephfs/cephfs.pyx

index 6bf24b1b7486ba7042ec41f83bf4397bc0a0ea95..975abd26c581a58cfbf7ec3776232fda661f2359 100644 (file)
@@ -183,7 +183,8 @@ cdef extern from "cephfs/libcephfs.h" nogil:
 
 
 class Error(Exception):
-    pass
+    def get_error_code(self):
+        return 1
 
 
 class OSError(Error):
@@ -195,6 +196,9 @@ class OSError(Error):
     def __str__(self):
         return '{} [Errno {}]'.format(self.strerror, self.errno)
 
+    def get_error_code(self):
+        return self.errno
+
 
 class PermissionError(OSError):
     pass