diff --git a/arango/client.py b/arango/client.py index 2b6e4993..0ccaa19f 100644 --- a/arango/client.py +++ b/arango/client.py @@ -12,7 +12,7 @@ JwtSuperuserConnection, ) from arango.database import StandardDatabase -from arango.exceptions import ServerConnectionError +from arango.exceptions import ArangoClientError, ServerConnectionError from arango.http import ( DEFAULT_REQUEST_TIMEOUT, DefaultHTTPClient, @@ -300,6 +300,6 @@ def db( except ServerConnectionError as err: raise err except Exception as err: - raise ServerConnectionError(f"bad connection: {err}") + raise ArangoClientError(f"bad connection: {err}") return StandardDatabase(connection) diff --git a/arango/connection.py b/arango/connection.py index d25d2f78..15ff3c70 100644 --- a/arango/connection.py +++ b/arango/connection.py @@ -226,9 +226,13 @@ def ping(self) -> int: request = Request(method="get", endpoint="/_api/collection") resp = self.send_request(request) if resp.status_code in {401, 403}: - raise ServerConnectionError("bad username/password or token is expired") + raise ServerConnectionError( + resp, request, "bad username/password or token is expired" + ) if not resp.is_success: # pragma: no cover - raise ServerConnectionError(resp.error_message or "bad server response") + raise ServerConnectionError( + resp, request, resp.error_message or "bad server response" + ) return resp.status_code @abstractmethod diff --git a/arango/exceptions.py b/arango/exceptions.py index 52ad8ffd..2adb718c 100644 --- a/arango/exceptions.py +++ b/arango/exceptions.py @@ -614,7 +614,7 @@ class PregelJobDeleteError(ArangoServerError): ##################### -class ServerConnectionError(ArangoClientError): +class ServerConnectionError(ArangoServerError): """Failed to connect to ArangoDB server.""" diff --git a/tests/test_client.py b/tests/test_client.py index e43180f7..a196a8fd 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -8,7 +8,7 @@ from arango.client import ArangoClient from arango.database import StandardDatabase -from arango.exceptions import ServerConnectionError +from arango.exceptions import ArangoClientError, ServerConnectionError from arango.http import DefaultHTTPClient, DeflateRequestCompression from arango.resolver import FallbackHostResolver, RandomHostResolver, SingleHostResolver from tests.helpers import ( @@ -89,7 +89,7 @@ def test_client_bad_connection(db, username, password, cluster): # Test connection with invalid host URL client = ArangoClient(hosts="http://127.0.0.1:8500") - with pytest.raises(ServerConnectionError) as err: + with pytest.raises(ArangoClientError) as err: client.db(db.name, username, password, verify=True) assert "bad connection" in str(err.value)