Skip to content

Commit b62a18b

Browse files
Tweaks to "usage" docs page
Move summary of exceptions to the beginning with links to subsections on the same page. Use instant data preview for exceptions, similar to functions. Use horizontal rules to separate main sections.
1 parent c8a3c34 commit b62a18b

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

docs/usage.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ module - `simplejustwatchapi`.
2929
Examples of parsed responses are in the GitHub repository in
3030
[`examples/`](https://github.com/Electronic-Mango/simple-justwatch-python-api/tree/main/examples).
3131

32+
---
33+
34+
Each function can raise two exceptions:
35+
36+
- [`JustWatchHttpError`](#http-errors) - JustWatch API responded with non-`2xx` code.
37+
- [`JustWatchApiError`](#api-errors) - JSON response from JustWatch API contains
38+
errors.
39+
40+
You can check [Exceptions](API Reference/exceptions.md) page for more details.
41+
42+
---
3243

3344
## Functions
3445

@@ -261,21 +272,15 @@ exact 3-letter code needed there.
261272
Example function call and its output is in
262273
[`examples/providers_output.py`](https://github.com/Electronic-Mango/simple-justwatch-python-api/blob/main/examples/providers_output.py).
263274

264-
275+
---
265276

266277
## Error handling
267278

268-
Each function can raise two exceptions:
269-
270-
| Exception | Cause |
271-
|----------------------------------------------------------------------------------------|-------|
272-
| [`JustWatchHttpError`][simplejustwatchapi.exceptions.JustWatchHttpError]{data-preview} | JustWatch API responded with non-`2xx` code. |
273-
| [`JustWatchApiError`][simplejustwatchapi.exceptions.JustWatchApiError]{data-preview} | JSON response from JustWatch API contains errors,<br>even though the API responded with a `2xx` status code. |
274-
275-
You can check [Exceptions](API Reference/exceptions.md) page for more details.
276-
277279
### HTTP errors
278280

281+
[`JustWatchHttpError`][simplejustwatchapi.exceptions.JustWatchHttpError]{data-preview}
282+
is raised when JustWatch API responds with non-`2xx` status code.
283+
279284
Non-`2xx` response status codes can happen when trying to use incorrect type for
280285
parameters, e.g., trying to use a non-numeric string for `count`:
281286

@@ -303,6 +308,10 @@ except JustWatchHttpError as e:
303308

304309
### API errors
305310

311+
[`JustWatchApiError`][simplejustwatchapi.exceptions.JustWatchApiError]{data-preview} is
312+
raised when JustWatch API **does** respond with `2xx` status code, but the internal JSON
313+
response contain errors.
314+
306315
API errors can occur for invalid country code:
307316
```python
308317
from simplejustwatchapi import search, JustWatchApiError
@@ -361,6 +370,7 @@ except JustWatchApiError as e:
361370
These are just examples of internal API errors, which cause [`JustWatchApiError`]
362371
[simplejustwatchapi.exceptions.JustWatchApiError] exception.
363372

373+
---
364374

365375
## More complicated examples
366376

0 commit comments

Comments
 (0)