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.")When the library is unable to connect to the API, for example due to a network failure or timeout, an abstime.APIConnectionError is thrown.
When the API returns a non-success status code, a subclass of abstime.AbsTimeError is thrown.
import * as abstime from "@abstime/sdk";
const client = new abstime.AbsTime();
try { await client.resolve({ text: "the last Friday of this month at 2 pm", refTime: "2026-04-09T17:30:00Z", refTimezone: "America/Los_Angeles", });} catch (err) { if (err instanceof abstime.InputError) { console.log(`Invalid input: ${err.message}`); } else if (err instanceof abstime.RateLimitError) { console.log(`Request ID: ${err.requestId}`); } else if (err instanceof abstime.APIConnectionError) { console.log("The API could not be reached."); }}Error codes are as follows:
| Status Code | Error |
|---|---|
400 | InputError |
401 | AuthenticationError |
403 | PermissionDeniedError |
429 | RateLimitError |
>=500 | InternalError |
N/A | APIConnectionError |