2011-05-04 16:45:24 +02:00
|
|
|
class OfflineImapError(Exception):
|
|
|
|
"""An Error during offlineimap synchronization"""
|
|
|
|
|
|
|
|
class ERROR:
|
2011-08-29 14:31:52 +02:00
|
|
|
"""Severity level of an Exception
|
|
|
|
|
|
|
|
* **MESSAGE**: Abort the current message, but continue with folder
|
2011-09-01 11:00:58 +02:00
|
|
|
* **FOLDER_RETRY**: Error syncing folder, but do retry
|
2011-08-29 14:31:52 +02:00
|
|
|
* **FOLDER**: Abort folder sync, but continue with next folder
|
|
|
|
* **REPO**: Abort repository sync, continue with next account
|
|
|
|
* **CRITICAL**: Immediately exit offlineimap
|
|
|
|
"""
|
2015-01-01 21:41:11 +01:00
|
|
|
|
2011-09-01 11:00:58 +02:00
|
|
|
MESSAGE, FOLDER_RETRY, FOLDER, REPO, CRITICAL = 0, 10, 15, 20, 30
|
2011-05-04 16:45:24 +02:00
|
|
|
|
|
|
|
def __init__(self, reason, severity, errcode=None):
|
|
|
|
"""
|
|
|
|
:param reason: Human readable string suitable for logging
|
|
|
|
|
|
|
|
:param severity: denoting which operations should be
|
|
|
|
aborted. E.g. a ERROR.MESSAGE can occur on a faulty
|
|
|
|
message, but a ERROR.REPO occurs when the server is
|
|
|
|
offline.
|
|
|
|
|
2011-08-29 14:31:52 +02:00
|
|
|
:param errcode: optional number denoting a predefined error
|
2011-05-04 16:45:24 +02:00
|
|
|
situation (which let's us exit with a predefined exit
|
|
|
|
value). So far, no errcodes have been defined yet.
|
|
|
|
|
|
|
|
:type severity: OfflineImapError.ERROR value"""
|
2015-01-01 21:41:11 +01:00
|
|
|
|
2011-05-04 16:45:24 +02:00
|
|
|
self.errcode = errcode
|
|
|
|
self.severity = severity
|
|
|
|
|
|
|
|
# 'reason' is stored in the Exception().args tuple.
|
|
|
|
super(OfflineImapError, self).__init__(reason)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def reason(self):
|
|
|
|
return self.args[0]
|