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:
Eygene Ryabinkin
2015-01-11 23:44:24 +03:00
parent 8c6abc413e
commit e7fabf9e57
15 changed files with 150 additions and 26 deletions

View File

@ -17,6 +17,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import re
from sys import exc_info
from offlineimap import imaputil, OfflineImapError
from offlineimap import imaplibutil
@ -144,7 +145,8 @@ class GmailFolder(IMAPFolder):
raise OfflineImapError("FETCHING UIDs in folder [%s]%s failed. " % \
(self.getrepository(), self) + \
"Server responded '[%s] %s'" % \
(res_type, response), OfflineImapError.ERROR.FOLDER)
(res_type, response), OfflineImapError.ERROR.FOLDER), \
None, exc_info()[2]
finally:
self.imapserver.releaseconnection(imapobj)