|
21 | 21 | logger = trino.logging.get_logger(__name__)
|
22 | 22 |
|
23 | 23 |
|
24 |
| -class HttpError(Exception): |
| 24 | +# PEP 249 Errors |
| 25 | +class Error(Exception): |
25 | 26 | pass
|
26 | 27 |
|
27 | 28 |
|
28 |
| -class Http502Error(Exception): |
| 29 | +class Warning(Exception): |
29 | 30 | pass
|
30 | 31 |
|
31 | 32 |
|
32 |
| -class Http503Error(HttpError): |
| 33 | +class InterfaceError(Error): |
33 | 34 | pass
|
34 | 35 |
|
35 | 36 |
|
36 |
| -class Http504Error(HttpError): |
| 37 | +class DatabaseError(Error): |
| 38 | + pass |
| 39 | + |
| 40 | + |
| 41 | +class InternalError(DatabaseError): |
| 42 | + pass |
| 43 | + |
| 44 | + |
| 45 | +class OperationalError(DatabaseError): |
| 46 | + pass |
| 47 | + |
| 48 | + |
| 49 | +class ProgrammingError(DatabaseError): |
| 50 | + pass |
| 51 | + |
| 52 | + |
| 53 | +class IntegrityError(DatabaseError): |
| 54 | + pass |
| 55 | + |
| 56 | + |
| 57 | +class DataError(DatabaseError): |
37 | 58 | pass
|
38 | 59 |
|
39 | 60 |
|
40 |
| -class TrinoError(Exception): |
| 61 | +class NotSupportedError(DatabaseError): |
41 | 62 | pass
|
42 | 63 |
|
43 | 64 |
|
44 |
| -class TrinoAuthError(Exception): |
| 65 | +# dbapi module errors (extending PEP 249 errors) |
| 66 | +class TrinoAuthError(OperationalError): |
45 | 67 | pass
|
46 | 68 |
|
47 | 69 |
|
48 |
| -class TrinoDataError(Exception): |
| 70 | +class TrinoDataError(NotSupportedError): |
49 | 71 | pass
|
50 | 72 |
|
51 | 73 |
|
52 |
| -class TrinoQueryError(Exception): |
| 74 | +class TrinoQueryError(Error): |
53 | 75 | def __init__(self, error, query_id=None):
|
54 | 76 | self._error = error
|
55 | 77 | self._query_id = query_id
|
@@ -100,70 +122,46 @@ def __str__(self):
|
100 | 122 | return repr(self)
|
101 | 123 |
|
102 | 124 |
|
103 |
| -class TrinoExternalError(TrinoQueryError): |
104 |
| - pass |
105 |
| - |
106 |
| - |
107 |
| -class TrinoInternalError(TrinoQueryError): |
108 |
| - pass |
109 |
| - |
110 |
| - |
111 |
| -class TrinoUserError(TrinoQueryError): |
112 |
| - pass |
113 |
| - |
114 |
| - |
115 |
| -# PEP 249 |
116 |
| -class Error(Exception): |
| 125 | +class TrinoExternalError(TrinoQueryError, OperationalError): |
117 | 126 | pass
|
118 | 127 |
|
119 | 128 |
|
120 |
| -class Warning(Exception): |
| 129 | +class TrinoInternalError(TrinoQueryError, InternalError): |
121 | 130 | pass
|
122 | 131 |
|
123 | 132 |
|
124 |
| -class InterfaceError(Error): |
| 133 | +class TrinoUserError(TrinoQueryError, ProgrammingError): |
125 | 134 | pass
|
126 | 135 |
|
127 | 136 |
|
128 |
| -class DatabaseError(Error): |
129 |
| - pass |
130 |
| - |
131 |
| - |
132 |
| -class InternalError(DatabaseError): |
133 |
| - pass |
134 |
| - |
135 |
| - |
136 |
| -class OperationalError(DatabaseError): |
137 |
| - pass |
138 |
| - |
139 |
| - |
140 |
| -class ProgrammingError(DatabaseError): |
| 137 | +class FailedToObtainAddedPrepareHeader(Error): |
| 138 | + """ |
| 139 | + Raise this exception when unable to find the 'X-Trino-Added-Prepare' |
| 140 | + header in the response of a PREPARE statement request. |
| 141 | + """ |
141 | 142 | pass
|
142 | 143 |
|
143 | 144 |
|
144 |
| -class IntegrityError(DatabaseError): |
| 145 | +class FailedToObtainDeallocatedPrepareHeader(Error): |
| 146 | + """ |
| 147 | + Raise this exception when unable to find the 'X-Trino-Deallocated-Prepare' |
| 148 | + header in the response of a DEALLOCATED statement request. |
| 149 | + """ |
145 | 150 | pass
|
146 | 151 |
|
147 | 152 |
|
148 |
| -class DataError(DatabaseError): |
| 153 | +# client module errors |
| 154 | +class HttpError(Exception): |
149 | 155 | pass
|
150 | 156 |
|
151 | 157 |
|
152 |
| -class NotSupportedError(DatabaseError): |
| 158 | +class Http502Error(HttpError): |
153 | 159 | pass
|
154 | 160 |
|
155 | 161 |
|
156 |
| -class FailedToObtainAddedPrepareHeader(Error): |
157 |
| - """ |
158 |
| - Raise this exception when unable to find the 'X-Trino-Added-Prepare' |
159 |
| - header in the response of a PREPARE statement request. |
160 |
| - """ |
| 162 | +class Http503Error(HttpError): |
161 | 163 | pass
|
162 | 164 |
|
163 | 165 |
|
164 |
| -class FailedToObtainDeallocatedPrepareHeader(Error): |
165 |
| - """ |
166 |
| - Raise this exception when unable to find the 'X-Trino-Deallocated-Prepare' |
167 |
| - header in the response of a DEALLOCATED statement request. |
168 |
| - """ |
| 166 | +class Http504Error(HttpError): |
169 | 167 | pass
|
0 commit comments