Exceptions¶
All Medha exceptions inherit from MedhaError, making it easy to catch any library error with a single handler.
from medha.exceptions import MedhaError
try:
async with Medha(...) as cache:
await cache.store(...)
except MedhaError as exc:
logger.error("Medha error: %s", exc)
Exception Hierarchy¶
| Exception | Raised When |
|---|---|
MedhaError |
Base class for all Medha exceptions |
ConfigurationError |
Invalid Settings values (e.g. threshold ordering violation) |
EmbeddingError |
Embedder fails to produce a vector (API error, model load failure) |
StorageError |
Vector backend read/write operation fails |
StorageInitializationError |
Backend cannot connect or create the collection at startup |
TemplateError |
A QueryTemplate is malformed or cannot be registered |
ParameterExtractionError |
Named entity extraction fails during template matching |
MedhaError¶
ConfigurationError¶
Bases: MedhaError
Raised when configuration is invalid or required environment variables are missing.
EmbeddingError¶
Bases: MedhaError
Raised when embedding generation fails.
StorageError¶
Bases: MedhaError
Raised when the vector storage backend encounters an error.
StorageInitializationError¶
Bases: StorageError
Raised when collection creation or storage initialization fails.
TemplateError¶
Bases: MedhaError
Raised when template loading, matching, or rendering fails.
ParameterExtractionError¶
Bases: MedhaError
Raised when required parameters cannot be extracted from the input.