Skip to content

Handling Errors

When the library is unable to connect to the API, for example due to a network failure or timeout, an abstime.APIConnectionError is raised.

When the API returns a non-success status code, a subclass of abstime.AbsTimeError is raised.

import abstime
client = abstime.AbsTime()
try:
result = client.resolve(
text="the last Friday of this month at 2 pm",
ref_time="2026-04-09T17:30:00Z",
ref_timezone="America/Los_Angeles",
)
except abstime.InputError as exc:
print(f"Invalid input: {exc}")
except abstime.RateLimitError as exc:
print(f"Request ID: {exc.request_id}")
except abstime.APIConnectionError:
print("The API could not be reached.")

Error codes are as follows:

Status CodeError
400InputError
401AuthenticationError
403PermissionDeniedError
429RateLimitError
>=500InternalError
N/AAPIConnectionError