Exceptions#

Valguard defines several exception classes for error handling related to value validation, configuration errors, and misuse of constraint-enforced types.

Base Class#

class valguard.exceptions.ValuesError[source]#

Bases: Exception

Base class for all exceptions raised by the values package.

Validation Errors#

class valguard.exceptions.ValidationError[source]#

Bases: ValuesError

Raised when a value fails validation.

Typically indicates that the value has the wrong type or violates a constraint.

class valguard.exceptions.TypeMismatchError[source]#

Bases: ValuesError

Raised 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, ValuesError

Raised 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: ValuesError

Raised 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.