"""Typed exceptions for the BLS client. Lets callers distinguish "you're throttled" from "your request was bad" — the two failure modes the old generic RuntimeError conflated. """ class BLSError(RuntimeError): """Base class for all BLS API errors.""" def __init__(self, message, *, status=None, messages=None): super().__init__(message) self.status = status # the API "status" field, e.g. REQUEST_FAILED self.messages = messages or [] # the API "message" list, verbatim class BLSRequestError(BLSError): """The API rejected the request (malformed series ID, bad year range, etc.).""" class BLSQuotaError(BLSError): """The daily query threshold was exceeded (500/day for a registered key, 25/day unregistered). Resets at midnight Eastern."""