Robustify (&fix) error throwing on APPEND
If APPEND raises abort(), the (typ, dat) variables will not be set, so we should not be using it for the OfflineImapError Exception string. Fixing and prettifying the string formatting a bit at the same time. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
parent
1b6d76345a
commit
953c58a9c9
@ -541,20 +541,17 @@ class IMAPFolder(BaseFolder):
|
|||||||
imapobj = self.imapserver.acquireconnection()
|
imapobj = self.imapserver.acquireconnection()
|
||||||
if not retry_left:
|
if not retry_left:
|
||||||
raise OfflineImapError("Saving msg in folder '%s', "
|
raise OfflineImapError("Saving msg in folder '%s', "
|
||||||
"repository '%s' failed. Server reponded; %s %s\n"
|
"repository '%s' failed. Server reponded: %s\n"
|
||||||
"Message content was: %s" %
|
"Message content was: %s" %
|
||||||
(self, self.getrepository(),
|
(self, self.getrepository(), str(e), dbg_output),
|
||||||
typ, dat, dbg_output),
|
|
||||||
OfflineImapError.ERROR.MESSAGE)
|
OfflineImapError.ERROR.MESSAGE)
|
||||||
retry_left -= 1
|
retry_left -= 1
|
||||||
except imapobj.error, e:
|
except imapobj.error, e: # APPEND failed
|
||||||
# If the server responds with 'BAD', append() raise()s directly.
|
# If the server responds with 'BAD', append()
|
||||||
# So we need to prepare a response ourselves.
|
# raise()s directly. So we catch that too.
|
||||||
typ, dat = 'BAD', str(e)
|
raise OfflineImapError("Saving msg folder '%s', repo '%s'"
|
||||||
if typ != 'OK': #APPEND failed
|
"failed. Server reponded: %s\nMessage content was: "
|
||||||
raise OfflineImapError("Saving msg in folder '%s', repository "
|
"%s" % (self, self.getrepository(), str(e), dbg_output),
|
||||||
"'%s' failed. Server reponded; %s %s\nMessage content was:"
|
|
||||||
" %s" % (self, self.getrepository(), typ, dat, dbg_output),
|
|
||||||
OfflineImapError.ERROR.MESSAGE)
|
OfflineImapError.ERROR.MESSAGE)
|
||||||
# Checkpoint. Let it write out stuff, etc. Eg searches for
|
# Checkpoint. Let it write out stuff, etc. Eg searches for
|
||||||
# just uploaded messages won't work if we don't do this.
|
# just uploaded messages won't work if we don't do this.
|
||||||
|
Loading…
Reference in New Issue
Block a user