Source code for ts_ids_core.errors

"""
Exceptions used throughout `ts_ids_core`.
"""


[docs] class MultipleTypesError(TypeError): """Field which should have one type has multiple types."""
[docs] class InvalidTypeError(TypeError): """Field has an invalid type."""
[docs] class NullableReferenceError(ValueError): """fields that contain a reference cannot be nullable."""
[docs] class WrongConstantError(ValueError): """Raised when the user passes a value to an abstract 'const' field."""
[docs] class InvalidSchemaMetadata(ValueError): """Raised when the IDS' JSON Schema contains an invalid top-level metadata value."""
[docs] class InvalidField(Exception): """ Invalid definition for the IDS field. Note that this error should only be raised during class creation. Raise a ``ValueError`` for invalid field values, e.g. in the body of a ``@field_validator`` method. """
[docs] class InvalidNonMandatoryField(InvalidField): """The Non-Mandatory Field of an IDS class is invalid."""
[docs] class UnimplementedAbstractField(InvalidField): """An abstract field is being used when instead a subclass should implement it in order to use it."""
[docs] class SchemaValidationError(ValueError): """Raised when a value is not consistent with the schema."""
[docs] class InvalidPrimaryKeyField(InvalidField): """Invalid primary key field definition."""
[docs] class InvalidForeignKeyField(InvalidField): """Invalid foreign key field definition."""
[docs] class InvalidForeignKeySchema(ValueError): """Invalid foreign key schema when creating JSON schema."""
[docs] class InvalidArrayShape(ValueError): """A multidimensional array has an invalid shape.""" def __init__(self): self.message = ( "An array with a non-uniform shape was found where a multidimensional " "array was expected. It must have the same length in every element of " "every dimension to be a valid multidimensional array." ) super().__init__(self.message)