You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/04_upgrading/upgrading_to_v3.mdx
+38Lines changed: 38 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -186,6 +186,44 @@ The default timeout tier assigned to each method on non-storage resource clients
186
186
187
187
If your code relied on the previous global timeout behavior, review the timeout tier on the methods you use and adjust via the `timeout` parameter or by overriding tier defaults on the <ApiLinkto="class/ApifyClient">`ApifyClient`</ApiLink> constructor (see [Tiered timeout system](#tiered-timeout-system) above).
188
188
189
+
## Exception subclasses for API errors
190
+
191
+
<ApiLinkto="class/ApifyApiError">`ApifyApiError`</ApiLink> now dispatches to a dedicated subclass based on the HTTP status code of the failed response. Instantiating `ApifyApiError` directly still works — it returns the most specific subclass for the status — so existing `except ApifyApiError` handlers are unaffected.
You can now branch on error kind without inspecting `status_code` or `type`:
206
+
207
+
```python
208
+
from apify_client import ApifyClient
209
+
from apify_client.errors import NotFoundError, RateLimitError
210
+
211
+
client = ApifyClient(token='MY-APIFY-TOKEN')
212
+
213
+
try:
214
+
run = client.run('some-run-id').get()
215
+
except NotFoundError:
216
+
run =None
217
+
except RateLimitError:
218
+
...
219
+
```
220
+
221
+
### Behavior change: `.get()` now returns `None` on any 404
222
+
223
+
As a consequence of the dispatch above, `.get()`-style convenience methods — which use `catch_not_found_or_throw` internally to swallow 404 responses and return `None` — now swallow **every** 404, regardless of the `error.type` string in the response body. Previously only 404 responses carrying the types `record-not-found` or `record-or-token-not-found` were swallowed; any other 404 was re-raised as `ApifyApiError`.
224
+
225
+
In practice this matters only if you relied on a `.get()` call raising for a 404 with an unusual error type — such cases now return `None` instead. If your code needs to distinguish between "resource missing" and "404 with an unexpected type", inspect `.type` on the returned response or catch <ApiLinkto="class/NotFoundError">`NotFoundError`</ApiLink> from non-`.get()` calls that do not use `catch_not_found_or_throw`.
226
+
189
227
## Snake_case `sort_by` values on `actors().list()`
190
228
191
229
The `sort_by` parameter of <ApiLinkto="class/ActorCollectionClient#list">`ActorCollectionClient.list()`</ApiLink> and <ApiLinkto="class/ActorCollectionClientAsync#list">`ActorCollectionClientAsync.list()`</ApiLink> now accepts pythonic snake_case values instead of the raw camelCase values used by the API.
0 commit comments