aeat.application.corpus_search._errors module

Typed errors for the on-host corpus-search grounding surface.

These are registered AeatError subclasses, so a corpus-search failure that reaches the CLI boundary renders as its proper category envelope (a REFUSED input/dependency refusal, an ERROR base) rather than collapsing into the generic INTERNAL unexpected-boundary path. Each class binds one registered ErrorCode (declared in core.errors.registry._application_part1) whose message_key supplies the localized envelope message; the free-form constructor message stays as the developer-facing str(exc) detail and the specifics ride on context — the same context / suggestion ergonomics the MCP tool layer already projects onto the envelope (the install hint, the offending query/limit/ref).

exception CorpusSearchError(message, *, context=None, suggestion=None)[source]

Bases: AeatError

Base error for the corpus-search grounding surface.

Parameters:
  • message (str)

  • context (Mapping[str, object] | None)

  • suggestion (str | None)

Return type:

None

code: ClassVar[ErrorCode]
exception CorpusSearchInputError(message, *, context=None, suggestion=None)[source]

Bases: CorpusSearchError

Raised when a corpus-search request cannot be satisfied.

Covers an unknown citation id, a corpus_ref whose backing extracted text is missing, an empty query, and any other caller-supplied input the surface refuses.

Parameters:
  • message (str)

  • context (Mapping[str, object] | None)

  • suggestion (str | None)

Return type:

None

code: ClassVar[ErrorCode]
exception CorpusSearchDependencyError(message, *, context=None, suggestion=None)[source]

Bases: CorpusSearchError

Raised when an operation needs the capability-gated search extra.

The lexical index and the citation lookup run on the standard library plus snowballstemmer and are always importable. Only the build-time embedding precompute and the runtime query embedder need the semantic stack (model2vec), which rides the aeat-cli[search] extra; when it is absent the surface refuses with an install hint (suggestion) rather than crashing, and the degraded lexical-only mode stays live.

Parameters:
  • message (str)

  • context (Mapping[str, object] | None)

  • suggestion (str | None)

Return type:

None

code: ClassVar[ErrorCode]