def __init__( self, received_data: Union[List, Dict], errors: Union[ListErrors, DictErrors] = None, message: str = "", ): """ Represent a client data validation error. :param received_data: Data triggering the error. Should be a list or a dictionary in most cases. :param errors: To be used if a specific field triggered the error. If received_data is a list: key is supposed to be the index in received_data value is supposed to be a the same as if received_data was the dictionary at this index If received_data is a dict: key is supposed to be the field name in error value is supposed to be a list of error messages on this field :param message: The error message in case errors cannot be provided. """ HTTPException.__init__(self, status_code=HTTPStatus.BAD_REQUEST.value) self.received_data = received_data self.errors = errors if errors else {"": [message]}
def __init__(self, detail: str = None): HTTPException.__init__( self, status_code=HTTPStatus.FORBIDDEN.value, detail=detail or HTTPStatus.FORBIDDEN.description, )
def __init__(self, detail: str = None): HTTPException.__init__( self, status_code=HTTPStatus.UNAUTHORIZED.value, detail=detail or HTTPStatus.UNAUTHORIZED.description, )