]> git.notmuchmail.org Git - notmuch/blobdiff - bindings/python-cffi/notmuch2/_errors.py
emacs: Add new option notmuch-search-hide-excluded
[notmuch] / bindings / python-cffi / notmuch2 / _errors.py
index 65064d4eda470cf8f90a25bf38f0c75bf53ac62f..17c3ad9cc39af7cf565f66aae9570bcba22a8f9c 100644 (file)
@@ -52,8 +52,12 @@ class NotmuchError(Exception):
                 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]
 
@@ -79,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'
 
@@ -99,7 +104,9 @@ 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 destroyed and it's memory freed.