X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=bindings%2Fpython-cffi%2Fnotmuch2%2F_errors.py;h=17c3ad9cc39af7cf565f66aae9570bcba22a8f9c;hb=8b737af28bc377db3e661a5744f3b7479b7ce485;hp=1c88763b95d1daa22f3d094c640360ec34149b04;hpb=e2df30f7a98f91543d0b3561dbb366eb4b3d812c;p=notmuch diff --git a/bindings/python-cffi/notmuch2/_errors.py b/bindings/python-cffi/notmuch2/_errors.py index 1c88763b..17c3ad9c 100644 --- a/bindings/python-cffi/notmuch2/_errors.py +++ b/bindings/python-cffi/notmuch2/_errors.py @@ -50,6 +50,14 @@ class NotmuchError(Exception): PathError, capi.lib.NOTMUCH_STATUS_ILLEGAL_ARGUMENT: IllegalArgumentError, + capi.lib.NOTMUCH_STATUS_NO_CONFIG: + NoConfigError, + capi.lib.NOTMUCH_STATUS_NO_DATABASE: + NoDatabaseError, + capi.lib.NOTMUCH_STATUS_DATABASE_EXISTS: + DatabaseExistsError, + capi.lib.NOTMUCH_STATUS_BAD_QUERY_SYNTAX: + QuerySyntaxError, } return types[status] @@ -75,7 +83,8 @@ class NotmuchError(Exception): if self.message: return self.message elif self.status: - return capi.lib.notmuch_status_to_string(self.status) + char_str = capi.lib.notmuch_status_to_string(self.status) + return capi.ffi.string(char_str).decode(errors='replace') else: return 'Unknown error' @@ -94,10 +103,13 @@ class UnsupportedOperationError(NotmuchError): pass class UpgradeRequiredError(NotmuchError): pass class PathError(NotmuchError): pass class IllegalArgumentError(NotmuchError): pass - +class NoConfigError(NotmuchError): pass +class NoDatabaseError(NotmuchError): pass +class DatabaseExistsError(NotmuchError): pass +class QuerySyntaxError(NotmuchError): pass class ObjectDestroyedError(NotmuchError): - """The object has already been destoryed and it's memory freed. + """The object has already been destroyed and it's memory freed. This occurs when :meth:`destroy` has been called on the object but you still happen to have access to the object. This should not