8000 fix: `ServerConnectionError` (#336) · arangodb/python-arango@dea2470 · GitHub
[go: up one dir, main page]

Skip to content

Commit dea2470

Browse files
authored
fix: ServerConnectionError (#336)
* fix: `ServerConnectionError` * fix: `test_client_bad_connection`
1 parent a0c5409 commit dea2470

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

arango/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
JwtSuperuserConnection,
1313
)
1414
from arango.database import StandardDatabase
15-
from arango.exceptions import ServerConnectionError
15+
from arango.exceptions import ArangoClientError, ServerConnectionError
1616
from arango.http import (
1717
DEFAULT_REQUEST_TIMEOUT,
1818
DefaultHTTPClient,
@@ -300,6 +300,6 @@ def db(
300300
except ServerConnectionError as err:
301301
raise err
302302
except Exception as err:
303-
raise ServerConnectionError(f"bad connection: {err}")
303+
raise ArangoClientError(f"bad connection: {err}")
304304

305305
return StandardDatabase(connection)

arango/connection.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,13 @@ def ping(self) -> int:
226226
request = Request(method="get", endpoint="/_api/collection")
227227
resp = self.send_request(request)
228228
if resp.status_code in {401, 403}:
229-
raise ServerConnectionError("bad username/password or token is expired")
229+
raise ServerConnectionError(
230+
resp, request, "bad username/password or token is expired"
231+
)
230232
if not resp.is_success: # pragma: no cover
231-
raise ServerConnectionError(resp.error_message or "bad server response")
233+
raise ServerConnectionError(
234+
resp, request, resp.error_message or "bad server response"
235+
)
232236
return resp.status_code
233237

234238
@abstractmethod

arango/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ class PregelJobDeleteError(ArangoServerError):
614614
#####################
615615

616616

617-
class ServerConnectionError(ArangoClientError):
617+
class ServerConnectionError(ArangoServerError):
618618
"""Failed to connect to ArangoDB server."""
619619

620620

tests/test_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from arango.client import ArangoClient
1010
from arango.database import StandardDatabase
11-
from arango.exceptions import ServerConnectionError
11+
from arango.exceptions import ArangoClientError, ServerConnectionError
1212
from arango.http import DefaultHTTPClient, DeflateRequestCompression
1313
from arango.resolver import FallbackHostResolver, RandomHostResolver, SingleHostResolver
1414
from tests.helpers import (
@@ -89,7 +89,7 @@ def test_client_bad_connection(db, username, password, cluster):
8989

9090
# Test connection with invalid host URL
9191
client = ArangoClient(hosts="http://127.0.0.1:8500")
92-
with pytest.raises(ServerConnectionError) as err:
92+
with pytest.raises(ArangoClientError) as err:
9393
client.db(db.name, username, password, verify=True)
9494
assert "bad connection" in str(err.value)
9595

0 commit comments

Comments
 (0)
0