File size: 1,001 Bytes
b4bfa19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
Exception hierarchy for recommendation system.

STRATEGY:
  - Retrieval/Recall failures: log, return empty list (graceful degradation).
  - Metadata/DB failures: log, propagate if critical; return empty/None for optional paths.
  - External API (web search, LLM): catch specific exceptions (Timeout, ConnectionError),
    log, fallback to cached or empty; avoid bare `except Exception` swallowing bugs.
  - Never use bare `except:` — always catch specific types or `Exception` with explicit log.
"""


class RecommendationError(Exception):
    """Base for all recommendation-related errors."""


class VectorDBError(RecommendationError):
    """ChromaDB, FTS5, or vector search failure."""


class MetadataStoreError(RecommendationError):
    """SQLite/metadata lookup failure."""


class RecallError(RecommendationError):
    """Recall model load or inference failure."""


class ExternalAPIError(RecommendationError):
    """Web search, Google Books API, or other external service failure."""