diff --git a/src/caosdb/common/models.py b/src/caosdb/common/models.py index 1cdbe6fb10f9843e940e45430076730d62b5e501..7760166f97233ded0431164ccef0492c223e2f80 100644 --- a/src/caosdb/common/models.py +++ b/src/caosdb/common/models.py @@ -50,7 +50,7 @@ from caosdb.connection.connection import get_connection from caosdb.connection.encode import MultipartParam, multipart_encode from caosdb.exceptions import (AmbiguityError, AuthorizationError, - CaosDBException, ConnectionError, + CaosDBException, CaosDBConnectionError, ConsistencyError, EmptyUniqueQueryError, EntityDoesNotExistError, EntityError, @@ -3758,7 +3758,7 @@ class Info(): c = get_connection() try: http_response = c.retrieve(["Info"]) - except ConnectionError as conn_e: + except CaosDBConnectionError as conn_e: print(conn_e) return diff --git a/src/caosdb/connection/connection.py b/src/caosdb/connection/connection.py index 0445f93b3c4e1a9fc4dcf5df71b0334ea73888e2..d7e4e2cd2b6bf2edd832c8a956d25e61587ac1b6 100644 --- a/src/caosdb/connection/connection.py +++ b/src/caosdb/connection/connection.py @@ -35,7 +35,7 @@ from socket import error as SocketError from caosdb.configuration import get_config from caosdb.exceptions import (CaosDBException, HTTPClientError, ConfigurationError, - ConnectionError, + CaosDBConnectionError, HTTPAuthorizationError, LoginFailedError, ResourceNotFoundError, @@ -136,7 +136,7 @@ class _DefaultCaosDBServerConnection(CaosDBServerConnection): self._http_con.request(method=method, url=self._base_path + path, headers=headers, body=body) except SocketError as socket_err: - raise ConnectionError( + raise CaosDBConnectionError( "Connection failed. Network or server down? " + str(socket_err) ) @@ -160,7 +160,7 @@ class _DefaultCaosDBServerConnection(CaosDBServerConnection): Raises ------ - ConnectionError + CaosDBConnectionError If no url has been specified, or if the CA certificate cannot be loaded. """ @@ -197,9 +197,9 @@ class _DefaultCaosDBServerConnection(CaosDBServerConnection): try: context.load_verify_locations(config["cacert"]) except Exception as exc: - raise ConnectionError("Could not load the cacert in" - "`{}`: {}".format(config["cacert"], - exc)) + raise CaosDBConnectionError("Could not load the cacert in" + "`{}`: {}".format(config["cacert"], + exc)) context.load_default_certs() @@ -208,7 +208,7 @@ class _DefaultCaosDBServerConnection(CaosDBServerConnection): host = parsed_url.netloc self._base_path = parsed_url.path else: - raise ConnectionError( + raise CaosDBConnectionError( "No connection url specified. Please " "do so via caosdb.configure_connection(...) or in a config " "file.") @@ -280,7 +280,7 @@ def _get_authenticator(**config): Raises ------ - ConnectionError + ConfigurationError If the password_method string cannot be resolved to a CaosAuthenticator class. """ diff --git a/src/caosdb/exceptions.py b/src/caosdb/exceptions.py index 8eb07f340e92a4a0cf40f54251636b2b57ce8c3b..9217febf86d0138673ae2ff54a0e4156d93b7198 100644 --- a/src/caosdb/exceptions.py +++ b/src/caosdb/exceptions.py @@ -89,7 +89,7 @@ class HTTPServerError(CaosDBException): CaosDBException.__init__(self, msg) -class ConnectionError(CaosDBException): +class CaosDBConnectionError(CaosDBException): """Connection is not configured or the network is down.""" def __init__(self, msg=None):