diff options
Diffstat (limited to 'docs/03_errors.rst')
-rw-r--r-- | docs/03_errors.rst | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/docs/03_errors.rst b/docs/03_errors.rst new file mode 100644 index 0000000..fce7af7 --- /dev/null +++ b/docs/03_errors.rst | |||
@@ -0,0 +1,36 @@ | |||
1 | Error handling | ||
2 | ============== | ||
3 | When Mastodon.py encounters an error, it will raise an exception, generally with | ||
4 | some text included to tell you what went wrong. | ||
5 | |||
6 | The base class that all Mastodon exceptions inherit from is `MastodonError`. | ||
7 | If you are only interested in the fact an error was raised somewhere in | ||
8 | Mastodon.py, and not the details, this is the exception you can catch. | ||
9 | |||
10 | `MastodonIllegalArgumentError` is generally a programming problem - you asked the | ||
11 | API to do something obviously invalid (i.e. specify a privacy option that does | ||
12 | not exist). | ||
13 | |||
14 | `MastodonFileNotFoundError` and `MastodonNetworkError` are IO errors - could be you | ||
15 | specified a wrong URL, could be the internet is down or your hard drive is | ||
16 | dying. They inherit from `MastodonIOError`, for easy catching. There is a sub-error | ||
17 | of `MastodonNetworkError`, `MastodonReadTimeout`, which is thrown when a streaming | ||
18 | API stream times out during reading. | ||
19 | |||
20 | `MastodonAPIError` is an error returned from the Mastodon instance - the server | ||
21 | has decided it can't fulfil your request (i.e. you requested info on a user that | ||
22 | does not exist). It is further split into `MastodonNotFoundError` (API returned 404) | ||
23 | and `MastodonUnauthorizedError` (API returned 401). Different error codes might exist, | ||
24 | but are not currently handled separately. | ||
25 | |||
26 | `MastodonMalformedEventError` is raised when a streaming API listener receives an | ||
27 | invalid event. There have been reports that this can sometimes happen after prolonged | ||
28 | operation due to an upstream problem in the requests/urllib libraries. | ||
29 | |||
30 | `MastodonRatelimitError` is raised when you hit an API rate limit. You should try | ||
31 | again after a while (see the rate limiting section above). | ||
32 | |||
33 | `MastodonServerError` is raised when the server throws an internal error, likely due | ||
34 | to server misconfiguration. | ||
35 | |||
36 | `MastodonVersionError` is raised when a version check for an API call fails. | ||