From c0540db92b75e021164c918ccf5ee339f9f1568b Mon Sep 17 00:00:00 2001 From: fspreck <f.spreckelsen@indiscale.com> Date: Thu, 14 Jan 2021 18:48:53 +0100 Subject: [PATCH] MAINT: Rename CaosDBConnectionError --- src/caosdb/common/models.py | 4 ++-- src/caosdb/connection/connection.py | 16 ++++++++-------- src/caosdb/exceptions.py | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/caosdb/common/models.py b/src/caosdb/common/models.py index 1cdbe6fb..7760166f 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 0445f93b..d7e4e2cd 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 8eb07f34..9217febf 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): -- GitLab