ADR 008 · Accepted

Error Handling Strategy

Status

Accepted (2024-02)

Context

LLM operations can fail due to:

  • Authentication issues.

  • Rate limiting.

  • Network errors.

  • Content filtering.

  • Invalid inputs.

Decision

Implement hierarchical exception system:

Key features:

  • All provider errors extend ProviderException (itself a RuntimeException).

  • FallbackChainExhaustedException is raised by FallbackMiddleware when every provider in the chain fails (ADR-021, ADR-026).

  • ProviderResponseException carries the offending HTTP status and a sanitised message (secrets stripped by ErrorMessageSanitizerTrait).

  • Exceptions include provider context.

Consequences

Positive:

  • ●● Granular error handling.

  • ● Provider-specific recovery strategies.

  • ● Clear exception hierarchy.

  • ● Actionable error information.

Negative:

  • ◑ Many exception classes.

  • ◑ Exception handling complexity.

  • ✕ Breaking changes in new versions.

Net Score: +5.0 (Positive impact - robust error handling enables graceful recovery strategies)

← All ADRs