File: error.py

package info (click to toggle)
offlineimap3 0.0~git20210225.1e7ef9e%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,328 kB
  • sloc: python: 7,974; sh: 548; makefile: 81
file content (39 lines) | stat: -rw-r--r-- 1,438 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
class OfflineImapError(Exception):
    """An Error during offlineimap synchronization"""

    class ERROR:
        """Severity level of an Exception

        * **MESSAGE**:  Abort the current message, but continue with folder
        * **FOLDER_RETRY**: Error syncing folder, but do retry
        * **FOLDER**:   Abort folder sync, but continue with next folder
        * **REPO**:     Abort repository sync, continue with next account
        * **CRITICAL**: Immediately exit offlineimap
        """

        MESSAGE, FOLDER_RETRY, FOLDER, REPO, CRITICAL = 0, 10, 15, 20, 30

    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.

        :param errcode: optional number denoting a predefined error
               situation (which let's us exit with a predefined exit
               value). So far, no errcodes have been defined yet.

        :type severity: OfflineImapError.ERROR value"""

        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]