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: try:
ret = self.client.sync() ret = self.client.sync()
except Exception, e: except Exception, e:
if isinstance(e[0], str): log = traceback.format_exc()
try:
err = unicode(e[0], "utf8", "ignore") err = unicode(e[0], "utf8", "ignore")
else: except:
# number, exception with no args, etc
err = "" err = ""
if "Unable to find the server" in err: if "Unable to find the server" in err:
self.fireEvent("offline") self.fireEvent("offline")
else: else:
err = traceback.format_exc() if not isinstance(log, unicode):
if not isinstance(err, unicode): err = unicode(log, "utf8", "replace")
err = unicode(err, "utf8", "replace") self.fireEvent("error", log)
self.fireEvent("error", err)
return return
if ret == "badAuth": if ret == "badAuth":
return self.fireEvent("badAuth") return self.fireEvent("badAuth")