error.py 2.1 KB
Newer Older
1
# encoding:UTF-8
S
slguan 已提交
2 3 4
"""Python exceptions
"""

5

S
slguan 已提交
6
class Error(Exception):
7
    def __init__(self, msg=None, errno=0xffff):
S
slguan 已提交
8 9
        self.msg = msg
        self.errno = errno
10
        self._full_msg = "[0x%04x]: %s" % (self.errno & 0xffff, self.msg)
11

S
slguan 已提交
12 13 14
    def __str__(self):
        return self._full_msg

15

S
slguan 已提交
16
class Warning(Exception):
17 18
    """Exception raised for important warnings like data truncations while inserting."""

S
slguan 已提交
19 20
    pass

21

S
slguan 已提交
22
class InterfaceError(Error):
23 24
    """Exception raised for errors that are related to the database interface rather than the database itself."""

S
slguan 已提交
25 26
    pass

27

S
slguan 已提交
28
class DatabaseError(Error):
29 30
    """Exception raised for errors that are related to the database."""

S
slguan 已提交
31 32
    pass

33 34 35
class ConnectionError(Error):
    """Exceptin raised for connection failed"""
    pass
36

S
slguan 已提交
37
class DataError(DatabaseError):
38 39
    """Exception raised for errors that are due to problems with the processed data like division by zero, numeric value out of range."""

S
slguan 已提交
40 41
    pass

42

S
slguan 已提交
43
class OperationalError(DatabaseError):
44 45
    """Exception raised for errors that are related to the database's operation and not necessarily under the control of the programmer"""

S
slguan 已提交
46 47 48 49
    pass


class IntegrityError(DatabaseError):
50 51
    """Exception raised when the relational integrity of the database is affected."""

S
slguan 已提交
52 53
    pass

54

S
slguan 已提交
55
class InternalError(DatabaseError):
56 57
    """Exception raised when the database encounters an internal error."""

S
slguan 已提交
58 59
    pass

60

S
slguan 已提交
61
class ProgrammingError(DatabaseError):
62 63
    """Exception raised for programming errors."""

S
slguan 已提交
64 65
    pass

66

S
slguan 已提交
67
class NotSupportedError(DatabaseError):
68 69
    """Exception raised in case a method or database API was used which is not supported by the database,."""

70
    pass
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85


class StatementError(DatabaseError):
    """Exception raised in STMT API."""

    pass

class ResultError(DatabaseError):
    """Result related APIs."""

    pass

class LinesError(DatabaseError):
    """taos_insert_lines errors."""

86 87 88 89 90 91 92 93 94 95 96
    pass

class TelnetLinesError(DatabaseError):
    """taos_insert_telnet_lines errors."""

    pass

class JsonPayloadError(DatabaseError):
    """taos_insert_json_payload errors."""

    pass