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