Skip to content
Snippets Groups Projects
Commit d8100717 authored by florian's avatar florian
Browse files

WIP: Use new HTTP errors instead of entity errors

parent 9921eda1
No related branches found
No related tags found
No related merge requests found
......@@ -33,10 +33,13 @@ from errno import EPIPE as BrokenPipe
from socket import error as SocketError
from caosdb.configuration import get_config
from caosdb.exceptions import (AuthorizationException, CaosDBException,
ClientErrorException, ConfigurationException,
ConnectionException, EntityDoesNotExistError,
LoginFailedException, ServerErrorException,
from caosdb.exceptions import (CaosDBException, ClientErrorException,
ConfigurationException,
ConnectionException,
HTTPAuthorizationException,
LoginFailedException,
ResourceNotFoundException,
ServerErrorException,
URITooLongException)
from caosdb.version import version
from pkg_resources import resource_filename
......@@ -88,7 +91,8 @@ class _DefaultCaosDBServerConnection(CaosDBServerConnection):
"""
def __init__(self):
self._useragent = ("caosdb-pylib/{version} - {implementation}".format(version=version, implementation=type(self).__name__))
self._useragent = ("caosdb-pylib/{version} - {implementation}".format(
version=version, implementation=type(self).__name__))
self._http_con = None
self._base_path = None
......@@ -397,11 +401,11 @@ def _handle_response_status(http_response):
"Request failed. The response returned with status "
"{}.".format(status))
elif status == 403:
raise AuthorizationException(
raise HTTPAuthorizationException(
"Request failed. The response returned with status "
"{}.".format(status))
elif status == 404:
raise EntityDoesNotExistError("This entity does not exist.")
raise ResourceNotFoundException("This entity does not exist.")
elif status in (413, 414):
raise URITooLongException(
"Request failed. The response returned with status "
......@@ -548,8 +552,8 @@ class _Connection(object): # pylint: disable=useless-object-inheritance
uri_segments.extend(path.split("/"))
return self.retrieve(entity_uri_segments=uri_segments)
except EntityDoesNotExistError:
raise EntityDoesNotExistError("This file does not exist.")
except ResourceNotFoundException:
raise ResourceNotFoundException("This file does not exist.")
def _login(self):
self._authenticator.login()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment