handle case where exception has no args

This commit is contained in:
Damien Elmes 2012-08-23 18:53:57 +09:00
parent 7be04bc2d5
commit 5d1376acb9

View file

@ -261,17 +261,18 @@ class SyncThread(QThread):
try:
ret = self.client.sync()
except Exception, e:
if isinstance(e[0], str):
log = traceback.format_exc()
try:
err = unicode(e[0], "utf8", "ignore")
else:
except:
# number, exception with no args, etc
err = ""
if "Unable to find the server" in err:
self.fireEvent("offline")
else:
err = traceback.format_exc()
if not isinstance(err, unicode):
err = unicode(err, "utf8", "replace")
self.fireEvent("error", err)
if not isinstance(log, unicode):
err = unicode(log, "utf8", "replace")
self.fireEvent("error", log)
return
if ret == "badAuth":
return self.fireEvent("badAuth")