This document contains assorted guidelines for programmers that want to hack OfflineIMAP.
OfflineIMAP on many occasions re-raises various exceptions and often changes exception type to
OfflineImapError. This is not a problem per se, but you must always remember that we need to preserve original tracebacks. This is not hard if you follow these simple rules.
For re-raising original exceptions, just use:
from inside your exception handling code.
If you need to change exception type, or its argument, or whatever, use this three-argument form:
In this form, you’re creating an instance of new exception, so
raise will deduce its
value parameters from the first argument, thus the second expression passed to
raise is always
And the third one is the traceback object obtained from the thread-safe
In fact, if you hadn’t already imported the whole
sys module, it will be better to import just
and raise like this::
since this is the historically-preferred style in the OfflineIMAP code.