tif1.exceptions module defines a comprehensive exception hierarchy for error handling throughout the library. All exceptions inherit from the base TIF1Error class and support structured context information.
Exception Hierarchy
Base Exception
TIF1Error
message: str- Human-readable error messagecontext: dict[str, Any]- Additional context information passed as kwargs
Data Errors
DataNotFoundError
year: int | None- Year of the eventevent: str | None- Event name or identifiersession: str | None- Session type**context- Additional context information
- Stores
year,event,sessionincontextdict - Plus any additional kwargs passed
- Session data not available for the specified year/event/session combination
- Event not found in the schedule
- Session type not available for the event
- Data source returns 404 or indicates data doesn’t exist
DriverNotFoundError
driver: str- Driver identifier that was not found**context- Additional context information
driver- The driver identifier that was searched for- Plus any additional kwargs passed
- Calling
session.get_driver()with an invalid driver code - Accessing
session.laps.pick_driver()with non-existent driver - Driver not participating in the session
- Invalid driver number or 3-letter code
LapNotFoundError
lap_number: int | None- Lap number that was not founddriver: str | None- Driver for whom the lap was searched**context- Additional context information
lap_number- The lap number searched fordriver- The driver identifier- Plus any additional kwargs passed
- Requesting a lap number that doesn’t exist for a driver
- Accessing out-of-range lap indices
- Driver didn’t complete the requested lap (DNF, DNS)
- Lap data not available or was deleted
Network Errors
NetworkError
url: str | None- URL that failedstatus_code: int | None- HTTP status code received**context- Additional context information
url- The URL that was requestedstatus_code- HTTP status code (e.g., 500, 503)- Plus any additional kwargs passed
- HTTP request timeout
- Server returns 5xx error
- Connection failure
- CDN unavailable
- Network connectivity issues
- Rate limiting (429)
- Circuit breaker open after repeated failures
Data Validation Errors
InvalidDataError
reason: str | None- Description of what is invalid**context- Additional context information
reason- Why the data is invalid- Plus any additional kwargs passed
- JSON parsing fails
- Data doesn’t match expected schema
- Required fields missing from response
- Data type mismatches
- Corrupted cache entries
- Invalid data format
Cache Errors
CacheError
- Cannot create cache directory
- SQLite database corruption
- Insufficient disk space for cache
- Cache database locked
- Permission errors on cache files
- Cache write failures
Session State Errors
SessionNotLoadedError
session.load().
Parameters:
attribute: str | None- The attribute that was accessed
attribute- Name of the attribute that requires loading
- Accessing
session.lapsbeforeload() - Accessing
session.resultsbeforeload() - Accessing
session.weatherbeforeload(laps=True, weather=True) - Accessing any data property that requires loaded data