Properly re-raise exception to save original tracebacks
We usually mutate some exceptions to OfflineImapError() and it is a whole lot better if such exception will show up with the original traceback, so all valid occurrences of such mutations were transformed to the 3-tuple form of "raise". Had also added coding guidelines document where this re-raise strategy is documented. Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
This commit is contained in:
@ -17,6 +17,7 @@
|
||||
|
||||
|
||||
import os
|
||||
from sys import exc_info
|
||||
from .Maildir import MaildirFolder
|
||||
from offlineimap import OfflineImapError
|
||||
import offlineimap.accounts
|
||||
@ -170,7 +171,8 @@ class GmailMaildirFolder(MaildirFolder):
|
||||
os.rename(tmppath, filepath)
|
||||
except OSError as e:
|
||||
raise OfflineImapError("Can't rename file '%s' to '%s': %s" % \
|
||||
(tmppath, filepath, e[1]), OfflineImapError.ERROR.FOLDER)
|
||||
(tmppath, filepath, e[1]), OfflineImapError.ERROR.FOLDER), \
|
||||
None, exc_info()[2]
|
||||
|
||||
if rtime != None:
|
||||
os.utime(filepath, (rtime, rtime))
|
||||
|
Reference in New Issue
Block a user