Skip to content
Snippets Groups Projects
Commit 8620cb09 authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

ENH: Add specific HTTP errors for 403 and 404

Should be used instead of the corresponding Entity Errors that are
currently misused as connection errors.
parent 45f552e0
No related branches found
No related tags found
No related merge requests found
...@@ -59,6 +59,9 @@ class ConfigurationException(CaosDBException): ...@@ -59,6 +59,9 @@ class ConfigurationException(CaosDBException):
_INFO = ("\n\nPlease check your ~/.pycaosdb.ini and your $PWD/" _INFO = ("\n\nPlease check your ~/.pycaosdb.ini and your $PWD/"
".pycaosdb.ini. Do at least one of them exist and are they correct?") ".pycaosdb.ini. Do at least one of them exist and are they correct?")
# TODO: Group the following errors (until TransactionError) according
# to their HTTP codes as children of client/server exception.
class ClientErrorException(CaosDBException): class ClientErrorException(CaosDBException):
def __init__(self, msg, status, body): def __init__(self, msg, status, body):
...@@ -110,6 +113,26 @@ class LoginFailedException(CaosDBException): ...@@ -110,6 +113,26 @@ class LoginFailedException(CaosDBException):
CaosDBException.__init__(self, msg=msg) CaosDBException.__init__(self, msg=msg)
class UnauthorizedException(CaosDBException):
"""You're lacking the required permissions. Corresponds to HTTP status
403.
"""
def __init__(self, msg=None):
CaosDBException.__init__(self, msg=msg)
class ResourceNotFoundException(CaosDBException):
"""The requested resource doesn't exist; corresponds to HTTP status
404.
"""
def __init__(self, msg=None):
CaosDBException.__init__(self, msg=msg)
class TransactionError(CaosDBException): class TransactionError(CaosDBException):
def _calc_bases(self): def _calc_bases(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment