Error types

Custom errors.

File: utils_pkg/klea_utils/errors.py

Copyright 2026 Ankur Sinha Author: Ankur Sinha <sanjay DOT ankur AT gmail DOT com>

exception klea_utils.errors.ClientContextError(message: str, *, status_code: int = 400)[source]

Bases: Exception

A client-supplied runtime context is untrusted or malformed.

Raised at the API boundary and mapped to a 4xx response; see klea_utils.client_context.

Parameters:
  • message – Human-readable reason.

  • status_code – HTTP status the API layer should use (400 for a malformed context, 403 for a non-loopback peer).

exception klea_utils.errors.LLMInitializationError[source]

Bases: Exception

class klea_utils.errors.LLMInvocationErrorCategory(*values)[source]

Bases: str, Enum

Classification of LLM invocation failures.

Providers report errors inconsistently, so the classification is a best-effort heuristic driven by tolerant regex matching (see klea_utils.llm.classify_llm_invocation_error). The category drives retry behaviour in the LLM nodes: some categories are retried with adjusted parameters, others surface immediately.

exception klea_utils.errors.PromptTemplateError[source]

Bases: Exception