error_handler#
Implements methods for general error handling.
- confirm_number_is_greater_or_equal_to_0(number: Union[int, float], param_name: str = 'param') None#
Checks that a number is greater or equal to 0.
- Parameters:
number – The number that gets confirmed.
param_name – Optional name to display in the error message.
- Raises:
ValueError – If param is < 0.
- confirm_number_is_greater_than_0(number: Union[int, float], param_name: str = 'param') None#
Checks that a number is greater than 0.
- Parameters:
number – The number that gets confirmed.
param_name – Optional name to display in the error message.
- Raises:
ValueError – If param <= 0.
- confirm_number_is_in_interval(number: Union[int, float], start_value: Union[int, float], end_value: Union[int, float], include_left: bool = True, include_right: bool = True, param_name: str = 'param') None#
Checks that a number lays in an intervall.
- Parameters:
number – The number that gets confirmed.
start_value – Start value of the intervall.
end_value – End value of the intervall.
include_left – Whether or not the start value is included in the intervall.
include_right – Whether or not the end value is included in the intervall.
param_name – Optional name to display in the error message.
- Raises:
ValueError – If number is not in the provided intervall.
- confirm_param_is_float(param: Any, param_name: str = 'param') None#
Checks that param is of type float.
- Parameters:
param – The param that gets confirmed.
param_name – Optional name to display in the error message.
- Raises:
TypeError – If param is not a float.
- confirm_param_is_float_or_int(param: Any, param_name: str = 'param') None#
Checks that param is of type float or int.
- Parameters:
param – The param that gets confirmed.
param_name – Optional name to display in the error message.
- Raises:
TypeError – If param is not a float or int.
- confirm_param_is_int(param: Any, param_name: str = 'param') None#
Checks that param is of type int.
- Parameters:
param – The param that gets confirmed.
param_name – Optional name to display in the error message.
- Raises:
TypeError – If param is not an int.
- confirm_sequence_contains_only_floats_or_ints(sequence_: Sequence[Any], param_name: str = 'param') None#
Checks that an iterable contains only floats and ints.
- Parameters:
sequence – The sequence that gets confirmed.
param_name – Optional name to display in the error message.
- Raises:
TypeError – If sequence contains other data types than float and int.
- confirm_sequence_is_not_empty(sequence_: Sequence[Any], param_name: str = 'param') None#
Checks that a sequence in not empty.
- Parameters:
sequence – The sequence that gets confirmed.
param_name – Optional name to display in the error message.
- Raises:
IndexError – If sequence is empty.