1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 """
18 ===============
19 DB Exceptions
20 ===============
21
22 DB Exceptions.
23 """
24 __author__ = u"Andr\xe9 Malo"
25 __docformat__ = "restructuredtext en"
26 __all__ = [
27 'DBError',
28 'DBConfigurationError',
29 'DBAPIError',
30
31 'InterfaceError',
32 'DatabaseError',
33 'DataError',
34 'OperationalError',
35 'IntegrityError',
36 'InternalError',
37 'ProgrammingError',
38 'NotSupportedError',
39 ]
40
41 import sys as _sys
42
43 from wtf import Error
44
45
47 """ Base DB exception """
48
50 """ DB configuration error """
51
54
56 """ Interface error """
57
59 """ Database error """
60
63
65 """ Operational error """
66
68 """ Integrity error """
69
71 """ Internal error """
72
74 """ Programming error """
75
77 """ Not supported error """
78
79
81 """
82 Translate exception to wtf.ext DBAPI exception
83
84 The new exception is raised.
85
86 :Parameters:
87 `adapter` : ``module``
88 DBAPI module
89
90 :Warning: This is a private function. Use
91 ``wtf.ext.db.driver(dbname).translate_exception()``.
92 """
93 e = _sys.exc_info()
94 try:
95 try:
96 raise
97 except adapter.NotSupportedError:
98 raise NotSupportedError, e[1], e[2]
99 except adapter.ProgrammingError:
100 raise ProgrammingError, e[1], e[2]
101 except adapter.InternalError:
102 raise InternalError, e[1], e[2]
103 except adapter.IntegrityError:
104 raise IntegrityError, e[1], e[2]
105 except adapter.OperationalError:
106 raise OperationalError, e[1], e[2]
107 except adapter.DataError:
108 raise DataError, e[1], e[2]
109 except adapter.DatabaseError:
110 raise DatabaseError, e[1], e[2]
111 except adapter.InterfaceError:
112 raise InterfaceError, e[1], e[2]
113 except adapter.Error:
114 raise DBAPIError, e[1], e[2]
115 finally:
116 del e
117