| id | error-handling |
|---|---|
| title | Error handling |
| description | Handle API errors with the ApifyApiError exception and automatic data parsing. |
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import CodeBlock from '@theme/CodeBlock';
import ApiLink from '@site/src/components/ApiLink';
import ErrorAsyncExample from '!!raw-loader!./code/04_error_async.py'; import ErrorSyncExample from '!!raw-loader!./code/04_error_sync.py';
When you use the Apify client, it automatically extracts all relevant data from the endpoint and returns it in the expected format. Date strings, for instance, are seamlessly converted to Python datetime.datetime objects. If an error occurs, the client raises an ApifyApiError. This exception wraps the raw JSON errors returned by the API and provides additional context, making it easier to debug any issues that arise.