Skip to content
You're viewing docs for Dev. See the latest version →

Errors

Pydantic-specific errors.

PydanticErrorMixin

A mixin class for common functionality shared by all Pydantic-specific errors.

Attributes

message

A message describing the error.

code

An optional error code from PydanticErrorCodes enum.

PydanticUserError

Bases: PydanticErrorMixin, TypeError

An error raised due to incorrect use of Pydantic.

PydanticUndefinedAnnotation

Bases: PydanticErrorMixin, NameError

A subclass of NameError raised when handling undefined annotations during CoreSchema generation.

Attributes

name

Name of the error.

message

Description of the error.

Methods

from_name_error

@classmethod

def from_name_error(cls, name_error: NameError) -> Self

Convert a NameError to a PydanticUndefinedAnnotation error.

Returns

Self — Converted PydanticUndefinedAnnotation error.

Parameters

name_error : NameError

NameError to be converted.

PydanticImportError

Bases: PydanticErrorMixin, ImportError

An error raised when an import fails due to module changes between V1 and V2.

Attributes

message

Description of the error.

PydanticSchemaGenerationError

Bases: PydanticUserError

An error raised during failures to generate a CoreSchema for some type.

Attributes

message

Description of the error.

PydanticInvalidForJsonSchema

Bases: PydanticUserError

An error raised during failures to generate a JSON schema for some CoreSchema.

Attributes

message

Description of the error.

PydanticForbiddenQualifier

Bases: PydanticUserError

An error raised if a forbidden type qualifier is found in a type annotation.