Module veryfi.errors
View Source
class VeryfiClientError(Exception):
optional_fields = ["error", "code"]
def __init__(self, raw_response, **error_info):
for field_name in self.optional_fields:
setattr(self, field_name, error_info.get(field_name))
self.raw_response = raw_response
self.status = raw_response.status_code
if getattr(self, "error"):
super().__init__(f"{self.status}, {getattr(self, 'error')}")
@staticmethod
def from_response(raw_response):
"""Veryfi API returns error messages with a json body
like:
{
'status': 'fail',
'error': 'Human readable error description.'
}
"""
error_cls = _error_map.get(raw_response.status_code) or VeryfiClientError
return error_cls(raw_response, **raw_response.json())
class UnauthorizedAccessToken(VeryfiClientError):
pass
class BadRequest(VeryfiClientError):
pass
class ResourceNotFound(VeryfiClientError):
pass
class UnexpectedHTTPMethod(VeryfiClientError):
pass
class AccessLimitReached(VeryfiClientError):
pass
class InternalError(VeryfiClientError):
pass
class ServiceUnavailable(VeryfiClientError):
pass
_error_map = {
400: BadRequest,
404: ResourceNotFound,
401: UnauthorizedAccessToken,
405: UnexpectedHTTPMethod,
409: AccessLimitReached,
500: InternalError,
503: ServiceUnavailable,
}
Classes
AccessLimitReached
class AccessLimitReached(
raw_response,
**error_info
)
Common base class for all non-exit exceptions.
View Source
class AccessLimitReached(VeryfiClientError):
pass
Ancestors (in MRO)
- veryfi.errors.VeryfiClientError
- builtins.Exception
- builtins.BaseException
Class variables
args
optional_fields
Static methods
from_response
def from_response(
raw_response
)
Veryfi API returns error messages with a json body
like: { 'status': 'fail', 'error': 'Human readable error description.' }
View Source
@staticmethod
def from_response(raw_response):
"""Veryfi API returns error messages with a json body
like:
{
'status': 'fail',
'error': 'Human readable error description.'
}
"""
error_cls = _error_map.get(raw_response.status_code) or VeryfiClientError
return error_cls(raw_response, **raw_response.json())
Methods
with_traceback
def with_traceback(
...
)
Exception.with_traceback(tb) --
set self.traceback to tb and return self.
BadRequest
class BadRequest(
raw_response,
**error_info
)
Common base class for all non-exit exceptions.
View Source
class BadRequest(VeryfiClientError):
pass
Ancestors (in MRO)
- veryfi.errors.VeryfiClientError
- builtins.Exception
- builtins.BaseException
Class variables
args
optional_fields
Static methods
from_response
def from_response(
raw_response
)
Veryfi API returns error messages with a json body
like: { 'status': 'fail', 'error': 'Human readable error description.' }
View Source
@staticmethod
def from_response(raw_response):
"""Veryfi API returns error messages with a json body
like:
{
'status': 'fail',
'error': 'Human readable error description.'
}
"""
error_cls = _error_map.get(raw_response.status_code) or VeryfiClientError
return error_cls(raw_response, **raw_response.json())
Methods
with_traceback
def with_traceback(
...
)
Exception.with_traceback(tb) --
set self.traceback to tb and return self.
InternalError
class InternalError(
raw_response,
**error_info
)
Common base class for all non-exit exceptions.
View Source
class InternalError(VeryfiClientError):
pass
Ancestors (in MRO)
- veryfi.errors.VeryfiClientError
- builtins.Exception
- builtins.BaseException
Class variables
args
optional_fields
Static methods
from_response
def from_response(
raw_response
)
Veryfi API returns error messages with a json body
like: { 'status': 'fail', 'error': 'Human readable error description.' }
View Source
@staticmethod
def from_response(raw_response):
"""Veryfi API returns error messages with a json body
like:
{
'status': 'fail',
'error': 'Human readable error description.'
}
"""
error_cls = _error_map.get(raw_response.status_code) or VeryfiClientError
return error_cls(raw_response, **raw_response.json())
Methods
with_traceback
def with_traceback(
...
)
Exception.with_traceback(tb) --
set self.traceback to tb and return self.
ResourceNotFound
class ResourceNotFound(
raw_response,
**error_info
)
Common base class for all non-exit exceptions.
View Source
class ResourceNotFound(VeryfiClientError):
pass
Ancestors (in MRO)
- veryfi.errors.VeryfiClientError
- builtins.Exception
- builtins.BaseException
Class variables
args
optional_fields
Static methods
from_response
def from_response(
raw_response
)
Veryfi API returns error messages with a json body
like: { 'status': 'fail', 'error': 'Human readable error description.' }
View Source
@staticmethod
def from_response(raw_response):
"""Veryfi API returns error messages with a json body
like:
{
'status': 'fail',
'error': 'Human readable error description.'
}
"""
error_cls = _error_map.get(raw_response.status_code) or VeryfiClientError
return error_cls(raw_response, **raw_response.json())
Methods
with_traceback
def with_traceback(
...
)
Exception.with_traceback(tb) --
set self.traceback to tb and return self.
ServiceUnavailable
class ServiceUnavailable(
raw_response,
**error_info
)
Common base class for all non-exit exceptions.
View Source
class ServiceUnavailable(VeryfiClientError):
pass
Ancestors (in MRO)
- veryfi.errors.VeryfiClientError
- builtins.Exception
- builtins.BaseException
Class variables
args
optional_fields
Static methods
from_response
def from_response(
raw_response
)
Veryfi API returns error messages with a json body
like: { 'status': 'fail', 'error': 'Human readable error description.' }
View Source
@staticmethod
def from_response(raw_response):
"""Veryfi API returns error messages with a json body
like:
{
'status': 'fail',
'error': 'Human readable error description.'
}
"""
error_cls = _error_map.get(raw_response.status_code) or VeryfiClientError
return error_cls(raw_response, **raw_response.json())
Methods
with_traceback
def with_traceback(
...
)
Exception.with_traceback(tb) --
set self.traceback to tb and return self.
UnauthorizedAccessToken
class UnauthorizedAccessToken(
raw_response,
**error_info
)
Common base class for all non-exit exceptions.
View Source
class UnauthorizedAccessToken(VeryfiClientError):
pass
Ancestors (in MRO)
- veryfi.errors.VeryfiClientError
- builtins.Exception
- builtins.BaseException
Class variables
args
optional_fields
Static methods
from_response
def from_response(
raw_response
)
Veryfi API returns error messages with a json body
like: { 'status': 'fail', 'error': 'Human readable error description.' }
View Source
@staticmethod
def from_response(raw_response):
"""Veryfi API returns error messages with a json body
like:
{
'status': 'fail',
'error': 'Human readable error description.'
}
"""
error_cls = _error_map.get(raw_response.status_code) or VeryfiClientError
return error_cls(raw_response, **raw_response.json())
Methods
with_traceback
def with_traceback(
...
)
Exception.with_traceback(tb) --
set self.traceback to tb and return self.
UnexpectedHTTPMethod
class UnexpectedHTTPMethod(
raw_response,
**error_info
)
Common base class for all non-exit exceptions.
View Source
class UnexpectedHTTPMethod(VeryfiClientError):
pass
Ancestors (in MRO)
- veryfi.errors.VeryfiClientError
- builtins.Exception
- builtins.BaseException
Class variables
args
optional_fields
Static methods
from_response
def from_response(
raw_response
)
Veryfi API returns error messages with a json body
like: { 'status': 'fail', 'error': 'Human readable error description.' }
View Source
@staticmethod
def from_response(raw_response):
"""Veryfi API returns error messages with a json body
like:
{
'status': 'fail',
'error': 'Human readable error description.'
}
"""
error_cls = _error_map.get(raw_response.status_code) or VeryfiClientError
return error_cls(raw_response, **raw_response.json())
Methods
with_traceback
def with_traceback(
...
)
Exception.with_traceback(tb) --
set self.traceback to tb and return self.
VeryfiClientError
class VeryfiClientError(
raw_response,
**error_info
)
Common base class for all non-exit exceptions.
View Source
class VeryfiClientError(Exception):
optional_fields = ["error", "code"]
def __init__(self, raw_response, **error_info):
for field_name in self.optional_fields:
setattr(self, field_name, error_info.get(field_name))
self.raw_response = raw_response
self.status = raw_response.status_code
if getattr(self, "error"):
super().__init__(f"{self.status}, {getattr(self, 'error')}")
@staticmethod
def from_response(raw_response):
"""Veryfi API returns error messages with a json body
like:
{
'status': 'fail',
'error': 'Human readable error description.'
}
"""
error_cls = _error_map.get(raw_response.status_code) or VeryfiClientError
return error_cls(raw_response, **raw_response.json())
Ancestors (in MRO)
- builtins.Exception
- builtins.BaseException
Descendants
- veryfi.errors.UnauthorizedAccessToken
- veryfi.errors.BadRequest
- veryfi.errors.ResourceNotFound
- veryfi.errors.UnexpectedHTTPMethod
- veryfi.errors.AccessLimitReached
- veryfi.errors.InternalError
- veryfi.errors.ServiceUnavailable
Class variables
args
optional_fields
Static methods
from_response
def from_response(
raw_response
)
Veryfi API returns error messages with a json body
like: { 'status': 'fail', 'error': 'Human readable error description.' }
View Source
@staticmethod
def from_response(raw_response):
"""Veryfi API returns error messages with a json body
like:
{
'status': 'fail',
'error': 'Human readable error description.'
}
"""
error_cls = _error_map.get(raw_response.status_code) or VeryfiClientError
return error_cls(raw_response, **raw_response.json())
Methods
with_traceback
def with_traceback(
...
)
Exception.with_traceback(tb) --
set self.traceback to tb and return self.