haiku.rag/haiku_rag_slim/haiku/rag/store/exceptions.py
Yiorgis Gozadinos 09a7076b7e
State what the code does, not what it replaced
Comments and docstrings across the branch narrated rejected
alternatives, consequences and history; each now states the current
contract. Renames test_a_legacy_uri_client_keeps_its_error to
test_an_unnamed_database_keeps_its_error. Documents the Sandbox
connection paths, the citation header's database segment, both
AmbiguousDatabaseError conditions on create_app, and run_inspector's
scope parameter. Doc paragraphs added by the branch in python.md,
storage.md and cli.md are one physical line each.
2026-08-28 15:13:52 +03:00

54 lines
1.6 KiB
Python

class ReadOnlyError(Exception):
"""Raised when a write operation is attempted on a read-only store."""
pass
class ConfigMismatchError(Exception):
"""Raised when stored config doesn't match current config."""
pass
class MigrationRequiredError(Exception):
"""Database requires migration. Run 'haiku-rag migrate' to upgrade."""
pass
class AmbiguousDatabaseError(Exception):
"""An operation that works on one database was asked of a configured set.
Raised by the CLI for a command that cannot tell which database to use, and
by the client for a method that has no meaning across several.
"""
class UnknownDatabaseError(KeyError):
"""A name that does not belong to the databases in question.
A `KeyError`, since selecting by name is a lookup, and one type wherever a
name is checked: at construction, per query, and when placing evidence.
"""
def __str__(self) -> str:
# KeyError quotes its argument, which reads as a missing dict key rather
# than the sentence this carries.
return str(self.args[0]) if self.args else ""
class AmbiguousCitationError(Exception):
"""A cited chunk id names a chunk in more than one database.
A citation records the id alone, so nothing downstream can say which
database it came from.
"""
class SourceUnavailableError(Exception):
"""A configured database could not be opened.
Carries the configured name and never the location: a path or URI in an
error message travels into logs and into whatever a consumer renders, and
the point of naming databases is that locations stay in the configuration.
"""