Exceptions#
Valguard defines several exception classes for error handling related to value validation, configuration errors, and misuse of constraint-enforced types.
Base Class#
Validation Errors#
- class valguard.exceptions.ValidationError[source]#
Bases:
ValuesErrorRaised when a value fails validation.
Typically indicates that the value has the wrong type or violates a constraint.
- class valguard.exceptions.TypeMismatchError[source]#
Bases:
ValuesErrorRaised when a value is accessed using an incompatible type-specific accessor.
For example, calling .as_int() on a BoolValue.
- class valguard.exceptions.ImplicitConversionError[source]#
Bases:
TypeError,ValuesErrorRaised when implicit type conversion is attempted on a Value instance.
For example, calling bool(value) instead of using .value or .as_bool().
Configuration Errors#
- class valguard.exceptions.ConfigurationError[source]#
Bases:
ValuesErrorRaised when an instance is misconfigured.
For example, an interval constraint with a lower bound greater than the upper bound, or an invalid parameter passed to a ConstrainedValueDict.