Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(
self,
message,
response=None
):
""" Exception based on requests library Response.
Args:
message(str): Exception message
response(:obj:`requests.Response`, optional): response object from requests library
"""
super(SplitwiseException, self).__init__(
message=message
)
if response is not None:
self.http_body = response.content,
self.http_status = response.status_code,
self.http_headers = response.headers
Args:
message(str): Exception message
response(:obj:`requests.Response`, optional): response object from requests library
"""
super(SplitwiseException, self).__init__(
message=message
)
if response is not None:
self.http_body = response.content,
self.http_status = response.status_code,
self.http_headers = response.headers
class SplitwiseUnauthorizedException(SplitwiseException):
""" Exception when request to splitwise is unauthorized
Inherits: :class:`splitwise.exception.SplitwiseException`
"""
pass
class SplitwiseBadRequestException(SplitwiseException):
""" Exception when request returns bad request
Inherits: :class:`splitwise.exception.SplitwiseException`
"""
pass
class SplitwiseNotAllowedException(SplitwiseException):
return response.content.decode("utf-8")
return response.content
if response.status_code == 401:
raise SplitwiseUnauthorizedException("Please check your token or consumer id and secret", response=response)
if response.status_code == 403:
raise SplitwiseNotAllowedException("You are not allowed to perform this operation", response=response)
if response.status_code == 400:
raise SplitwiseBadRequestException("Please check your request", response=response)
if response.status_code == 404:
raise SplitwiseNotFoundException("Required resource is not found", response)
raise SplitwiseException("Unknown error happened", response)
if response is not None:
self.http_body = response.content,
self.http_status = response.status_code,
self.http_headers = response.headers
class SplitwiseUnauthorizedException(SplitwiseException):
""" Exception when request to splitwise is unauthorized
Inherits: :class:`splitwise.exception.SplitwiseException`
"""
pass
class SplitwiseBadRequestException(SplitwiseException):
""" Exception when request returns bad request
Inherits: :class:`splitwise.exception.SplitwiseException`
"""
pass
class SplitwiseNotAllowedException(SplitwiseException):
""" Exception when request to splitwise is not allowed
Inherits: :class:`splitwise.exception.SplitwiseException`
"""
pass
class SplitwiseNotFoundException(SplitwiseException):
""" Exception when request to splitwise is unauthorized
Inherits: :class:`splitwise.exception.SplitwiseException`
"""
pass
class SplitwiseBadRequestException(SplitwiseException):
""" Exception when request returns bad request
Inherits: :class:`splitwise.exception.SplitwiseException`
"""
pass
class SplitwiseNotAllowedException(SplitwiseException):
""" Exception when request to splitwise is not allowed
Inherits: :class:`splitwise.exception.SplitwiseException`
"""
pass
class SplitwiseNotFoundException(SplitwiseException):
""" Exception when request to splitwise returns not found
Inherits: :class:`splitwise.exception.SplitwiseBaseException`
"""
pass
""" Exception when request returns bad request
Inherits: :class:`splitwise.exception.SplitwiseException`
"""
pass
class SplitwiseNotAllowedException(SplitwiseException):
""" Exception when request to splitwise is not allowed
Inherits: :class:`splitwise.exception.SplitwiseException`
"""
pass
class SplitwiseNotFoundException(SplitwiseException):
""" Exception when request to splitwise returns not found
Inherits: :class:`splitwise.exception.SplitwiseBaseException`
"""
pass