python: fix NotmuchError.__str__ if status == None
authorJustus Winter <4winter@informatik.uni-hamburg.de>
Mon, 26 Sep 2011 01:05:32 +0000 (03:05 +0200)
committerSebastian Spaeth <Sebastian@SSpaeth.de>
Thu, 29 Sep 2011 07:16:34 +0000 (09:16 +0200)
Passing None to STATUS.status2str raises an ArgumentError. Add a
check for this case and provide a generic message.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
bindings/python/notmuch/globals.py

index 2a57c411f3b6c4a07f61ec069c59397efe928059..097ab96800d1dcaa3336f037605be61561b1d0fd 100644 (file)
@@ -99,8 +99,10 @@ class NotmuchError(Exception):
     def __str__(self):
         if self.message is not None:
             return self.message
-        else:
+        elif self.status is not None:
             return STATUS.status2str(self.status)
+        else:
+            return 'Unknown error'
 
 def _str(value):
     """Ensure a nicely utf-8 encoded string to pass to libnotmuch