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

@ -14,6 +14,8 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
from sys import exc_info
from threading import Lock
from offlineimap import OfflineImapError
from .IMAP import IMAPFolder
@ -60,7 +62,7 @@ class MappedIMAPFolder(IMAPFolder):
line = line.strip()
except ValueError:
raise Exception("Corrupt line '%s' in UID mapping file '%s'"%
(line, mapfilename))
(line, mapfilename)), None, exc_info()[2]
(str1, str2) = line.split(':')
loc = long(str1)
rem = long(str2)
@ -89,7 +91,7 @@ class MappedIMAPFolder(IMAPFolder):
raise OfflineImapError("Could not find UID for msg '{0}' (f:'{1}'."
" This is usually a bad thing and should be reported on the ma"
"iling list.".format(e.args[0], self),
OfflineImapError.ERROR.MESSAGE)
OfflineImapError.ERROR.MESSAGE), None, exc_info()[2]
# Interface from BaseFolder
def cachemessagelist(self):