Skip to content

pydantic_jsonpointer.errors

pydantic_jsonpointer.errors

Error types for pointer-traversal APIs.

Kept in a dedicated module so that the adapter layer (which must raise these) can import them without depending on the traversal layer, which would create an import cycle.

AdapterNotFoundError

Bases: PointerError, TypeError

Raised when no ContainerAdapter is registered for a value's type.

ImmutableTargetError

Bases: PointerError

Raised when set/add/remove is attempted on a target that is under a frozen binding (transitive). See BaseModelAdapter.is_step_frozen.

InvalidTokenError

Bases: PointerError, ValueError

Raised when a token cannot be resolved against the current container (e.g. non-decimal token for a list, unknown field name for a model).

PointerError

Bases: Exception

Base class for all pointer-traversal errors.

PointerNotFoundError

Bases: PointerError, KeyError

Raised when a path step expects a value to exist and it does not.

Inherits from KeyError so callers can except KeyError. __str__ is overridden because KeyError.__str__ calls repr on its single arg, which would wrap our already human-readable messages in stray quotes (e.g. "'missing key'" instead of missing key).

RootRebindError

Bases: PointerError

Raised when set/add/remove is attempted on the root Ptr.

Python functions cannot rebind a caller's variable; callers must replace the document themselves.