RuleError Class

class kwhelp.exceptions.RuleError(**kwargs)[source]

Rule Error

__init__(**kwargs)[source]

Constructor

Keyword Arguments
  • err_rule (Type[IRule], optional) – Rule that caused exception.

  • rules_all (Iterable[Type[IRule]], optional) – List of rules that were to all be matched. One of these rules is usually the reason this exception is being raised.

  • rules_any (Iterable[Type[IRule]], optional) – List of rules that required one or more matches. One of these rules is usually the reason this exception is being raised.

  • arg_name (str, optional) – Name of the argument for this exception.

  • errors (Union[Exception, Iterable[Exception]], optional) – Exception or Exceptions that cause this error.

  • fn_name (str, optional) – Name of function/property that raise error.

  • msg (str, optional) – Optional message to append.

static from_rule_error(rule_error: kwhelp.exceptions.RuleError, **kwargs) kwhelp.exceptions.RuleError[source]

Creates a new RuleError from an existing RuleError

Parameters

rule_error (RuleError) – Current instance of RuleError use to base return value on.

Keyword Arguments

kwargs – One or more Key, Value properties that will replace property of rule_error.

Returns

New RuleError instance with updated properties included in **kwargs.

Return type

RuleError

property arg_name: Optional[str]

Gets Name of the argument for this exception

property err_rule: Optional[Type[kwhelp.rules.IRule]]

Gets rule that caused exception.

property errors: Optional[Union[Exception, Iterable[Exception]]]

Gets Exception or Exceptions that cause this error

property fn_name: Union[None, str]

Gets the function/property name that raised the error

property msg: Optional[str]

Gets any messsage that is appended

property rules_all: List[Type[kwhelp.rules.IRule]]

Gets list of rules that were to all be matched.

property rules_any: List[Type[kwhelp.rules.IRule]]

Gets of rules that required one or more matches.