Skip to content

Better error handling for unexpected server responses #195

Description

@bchopson

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions