refactor(data): unify vendor errors under a VendorError hierarchy

Every condition where a vendor cannot return usable data now derives from a
single VendorError base (errors.py): NoMarketDataError, VendorRateLimitError,
and VendorNotConfiguredError (still a ValueError for back-compat). Vendor-named
errors subclass the generic bases, and the router catches the base types, so a
new vendor needs no new except clause. Not-configured now has explicit
try-next-vendor handling instead of falling through the generic catch-all. The
number of error types tracks the number of distinct router reactions, not the
number of causes.
This commit is contained in:
Yijia-Xiao committed 2026-06-14 07:10:15 +00:00
1 parent db059034a2
commit 7df18fc912
7 files changed
+226 -64

No files matched your search

+6 -4
View File
@@ -14,6 +14,8 @@ from datetime import datetime, timedelta
import requests
from .errors import VendorNotConfiguredError
logger = logging.getLogger(__name__)
FRED_API_BASE = "https://api.stlouisfed.org/fred"
@@ -70,12 +72,12 @@ MACRO_SERIES = {
}
class FredNotConfiguredError(ValueError):
class FredNotConfiguredError(VendorNotConfiguredError):
"""Raised when FRED is selected but no API key is configured.
Subclasses ValueError so callers already catching ValueError keep working,
while the routing layer can distinguish a "vendor unavailable" condition
from a genuine data error (same contract as AlphaVantageNotConfiguredError).
A VendorNotConfiguredError (and thus still a ValueError), so the routing
layer's "vendor unavailable" handling and existing ValueError callers both
keep working.
"""