SamsException – Base Error

class SamsException(payload: Optional[Dict[str, Any]] = None, exception: Optional[Exception] = None)

Base class used for all SAMS Errors

Variables
get_name()str

Returns the class name of the exception. For example:

SamsSetErrors.InvalidStateTransition('usable').get_name()
'InvalidStateTransition'
__str__()str

Returns a string containing all relevant information For example:

str(SamsSetErrors.InvalidStateTransition('usable'))
'Error[07001] - InvalidStateTransition: Cannot change state from "usable" to draft'
to_dict()Dict[str, str]

Returns a dictionary with all the relevant information

This is used for constructing the response to send to the client. For example:

SamsSetErrors.InvalidStateTransition('usable').to_dict()
{
    'error': '07001',
    'name': 'InvalidStateTransition',
    'description': 'Cannot change state from "usable" to draft'
}
to_error_response()Tuple[Union[Dict[str, str], str], int]

Returns a tuple containing a results of to_dict() and http_code For example:

SamsSetErrors.InvalidStateTransition('usable').to_error_response()
{
    'error': '07001',
    'name': 'InvalidStateTransition',
    'description': 'Cannot change state from "usable" to draft'
},
400