Error Modules
This module contains the base class for handing errors in the application. It provides the building blocks for creating error classes that can be used to store errors for specific fields.
- class action_triggers.error.base.ErrorBase[source]
Bases:
object
A base class for storing errors for a set of fields. For each field, an error can be added using the add_<field_name>_error method.
- Parameters:
error_class – The class of the error to raise when the error is not valid.
Example:
class MyError(ErrorBase): field_1 = ErrorField("field_1") field_2 = ErrorField("field_2") error = MyError() error.add_field_1_error("key_1", "message_1") error.add_field_1_error("key_1", "message_2") error.add_field_2_error("key_2", "message_3") error.as_dict() # { # "field_1": {"key_1": ["message_1", "message_2"]}, # "field_2": {"key_2": ["message_3"]}, # } # Raises an exception if the error is not valid. error.is_valid(raise_exception=True)
- as_dict() dict [source]
Return the error message as a dictionary.
- Returns:
A dictionary containing the errors.
- error_class
alias of
Exception