-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexceptions.py
319 lines (180 loc) · 7.77 KB
/
exceptions.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
from typing import Optional
from arangoasync.request import Request
from arangoasync.response import Response
class ArangoError(Exception):
"""Base class for all exceptions in python-arango-async."""
class ArangoClientError(ArangoError):
"""Base class for all client-related exceptions.
Args:
msg (str): Error message.
Attributes:
source (str): Source of the error (always set to "client")
message (str): Error message.
"""
source = "client"
def __init__(self, msg: str) -> None:
super().__init__(msg)
self.message = msg
class ArangoServerError(ArangoError):
"""Base class for all server-related exceptions.
Args:
resp (Response): HTTP response object.
request (Request): HTTP request object.
msg (str | None): Error message.
Attributes:
source (str): Source of the error (always set to "server")
message (str): Error message.
url (str): URL of the request.
response (Response): HTTP response object.
request (Request): HTTP request object.
http_method (str): HTTP method of the request.
http_code (int): HTTP status code of the response.
http_headers (dict): HTTP headers of the response.
"""
source = "server"
def __init__(
self, resp: Response, request: Request, msg: Optional[str] = None
) -> None:
if msg is None:
msg = resp.error_message or resp.status_text
else:
msg = f"{msg} ({resp.error_message or resp.status_text})"
self.error_message = resp.error_message
self.error_code = resp.error_code
if self.error_code is not None:
msg = f"[HTTP {resp.status_code}][ERR {self.error_code}] {msg}"
else:
msg = f"[HTTP {resp.status_code}] {msg}"
self.error_code = resp.status_code
super().__init__(msg)
self.message = msg
self.url = resp.url
self.response = resp
self.request = request
self.http_method = resp.method.name
self.http_code = resp.status_code
self.http_headers = resp.headers
class AQLCacheClearError(ArangoServerError):
"""Failed to clear the query cache."""
class AQLCacheConfigureError(ArangoServerError):
"""Failed to configure query cache properties."""
class AQLCacheEntriesError(ArangoServerError):
"""Failed to retrieve AQL cache entries."""
class AQLCachePropertiesError(ArangoServerError):
"""Failed to retrieve query cache properties."""
class AQLQueryClearError(ArangoServerError):
"""Failed to clear slow AQL queries."""
class AQLQueryExecuteError(ArangoServerError):
"""Failed to execute query."""
class AQLQueryExplainError(ArangoServerError):
"""Failed to parse and explain query."""
class AQLQueryKillError(ArangoServerError):
"""Failed to kill the query."""
class AQLQueryListError(ArangoServerError):
"""Failed to retrieve running AQL queries."""
class AQLQueryRulesGetError(ArangoServerError):
"""Failed to retrieve AQL query rules."""
class AQLQueryTrackingGetError(ArangoServerError):
"""Failed to retrieve AQL tracking properties."""
class AQLQueryTrackingSetError(ArangoServerError):
"""Failed to configure AQL tracking properties."""
class AQLQueryValidateError(ArangoServerError):
"""Failed to parse and validate query."""
class AuthHeaderError(ArangoClientError):
"""The authentication header could not be determined."""
class CollectionCreateError(ArangoServerError):
"""Failed to create collection."""
class CollectionDeleteError(ArangoServerError):
"""Failed to delete collection."""
class CollectionListError(ArangoServerError):
"""Failed to retrieve collections."""
class CollectionPropertiesError(ArangoServerError):
"""Failed to retrieve collection properties."""
class ClientConnectionAbortedError(ArangoClientError):
"""The connection was aborted."""
class ClientConnectionError(ArangoClientError):
"""The request was unable to reach the server."""
class CursorCloseError(ArangoServerError):
"""Failed to delete the cursor result from server."""
class CursorCountError(ArangoClientError, TypeError):
"""The cursor count was not enabled."""
class CursorEmptyError(ArangoClientError):
"""The current batch in cursor was empty."""
class CursorNextError(ArangoServerError):
"""Failed to retrieve the next result batch from server."""
class CursorStateError(ArangoClientError):
"""The cursor object was in a bad state."""
class DatabaseCreateError(ArangoServerError):
"""Failed to create database."""
class DatabaseDeleteError(ArangoServerError):
"""Failed to delete database."""
class DatabaseListError(ArangoServerError):
"""Failed to retrieve databases."""
class DatabasePropertiesError(ArangoServerError):
"""Failed to retrieve database properties."""
class DeserializationError(ArangoClientError):
"""Failed to deserialize the server response."""
class DocumentGetError(ArangoServerError):
"""Failed to retrieve document."""
class DocumentInsertError(ArangoServerError):
"""Failed to insert document."""
class DocumentParseError(ArangoClientError):
"""Failed to parse document input."""
class DocumentRevisionError(ArangoServerError):
"""The expected and actual document revisions mismatched."""
class IndexCreateError(ArangoServerError):
"""Failed to create collection index."""
class IndexDeleteError(ArangoServerError):
"""Failed to delete collection index."""
class IndexGetError(ArangoServerError):
"""Failed to retrieve collection index."""
class IndexListError(ArangoServerError):
"""Failed to retrieve collection indexes."""
class IndexLoadError(ArangoServerError):
"""Failed to load indexes into memory."""
class JWTRefreshError(ArangoClientError):
"""Failed to refresh the JWT token."""
class JWTSecretListError(ArangoServerError):
"""Failed to retrieve information on currently loaded JWT secrets."""
class JWTSecretReloadError(ArangoServerError):
"""Failed to reload JWT secrets."""
class PermissionGetError(ArangoServerError):
"""Failed to retrieve user permission."""
class PermissionListError(ArangoServerError):
"""Failed to list user permissions."""
class PermissionResetError(ArangoServerError):
"""Failed to reset user permission."""
class PermissionUpdateError(ArangoServerError):
"""Failed to update user permission."""
class SerializationError(ArangoClientError):
"""Failed to serialize the request."""
class ServerConnectionError(ArangoServerError):
"""Failed to connect to ArangoDB server."""
class ServerStatusError(ArangoServerError):
"""Failed to retrieve server status."""
class ServerVersionError(ArangoServerError):
"""Failed to retrieve server version."""
class TransactionAbortError(ArangoServerError):
"""Failed to abort transaction."""
class TransactionCommitError(ArangoServerError):
"""Failed to commit transaction."""
class TransactionExecuteError(ArangoServerError):
"""Failed to execute JavaScript transaction."""
class TransactionInitError(ArangoServerError):
"""Failed to initialize transaction."""
class TransactionListError(ArangoServerError):
"""Failed to retrieve transactions."""
class TransactionStatusError(ArangoServerError):
"""Failed to retrieve transaction status."""
class UserCreateError(ArangoServerError):
"""Failed to create user."""
class UserDeleteError(ArangoServerError):
"""Failed to delete user."""
class UserGetError(ArangoServerError):
"""Failed to retrieve user details."""
class UserListError(ArangoServerError):
"""Failed to retrieve users."""
class UserReplaceError(ArangoServerError):
"""Failed to replace user."""
class UserUpdateError(ArangoServerError):
"""Failed to update user."""