|
if response.status_code != 200: |
|
error = ResponseError.model_validate_json(json.dumps(json_data)) |
|
if response.status_code >= 500: |
|
raise TravelTimeServerError(error.description) |
If the server returns an error and the json doesn't match the expected format, this bubbles up to the caller as a pydantic validation error. I suggest wrapping pydantic validation failures in a generic TravelTimeError. This makes error handling easier for callers.
traveltime-python-sdk/traveltimepy/sync_base_client.py
Lines 282 to 285 in 2954619
If the server returns an error and the json doesn't match the expected format, this bubbles up to the caller as a pydantic validation error. I suggest wrapping pydantic validation failures in a generic TravelTimeError. This makes error handling easier for callers.