aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mastodon/errors.py')
-rw-r--r--mastodon/errors.py90
1 files changed, 90 insertions, 0 deletions
diff --git a/mastodon/errors.py b/mastodon/errors.py
new file mode 100644
index 0000000..85cc313
--- /dev/null
+++ b/mastodon/errors.py
@@ -0,0 +1,90 @@
1# error.py - error classes
2
3##
4# Exceptions
5##
6class MastodonError(Exception):
7 """Base class for Mastodon.py exceptions"""
8
9
10class MastodonVersionError(MastodonError):
11 """Raised when a function is called that the version of Mastodon for which
12 Mastodon.py was instantiated does not support"""
13
14
15class MastodonIllegalArgumentError(ValueError, MastodonError):
16 """Raised when an incorrect parameter is passed to a function"""
17 pass
18
19
20class MastodonIOError(IOError, MastodonError):
21 """Base class for Mastodon.py I/O errors"""
22
23
24class MastodonFileNotFoundError(MastodonIOError):
25 """Raised when a file requested to be loaded can not be opened"""
26 pass
27
28
29class MastodonNetworkError(MastodonIOError):
30 """Raised when network communication with the server fails"""
31 pass
32
33
34class MastodonReadTimeout(MastodonNetworkError):
35 """Raised when a stream times out"""
36 pass
37
38
39class MastodonAPIError(MastodonError):
40 """Raised when the mastodon API generates a response that cannot be handled"""
41 pass
42
43
44class MastodonServerError(MastodonAPIError):
45 """Raised if the Server is malconfigured and returns a 5xx error code"""
46 pass
47
48
49class MastodonInternalServerError(MastodonServerError):
50 """Raised if the Server returns a 500 error"""
51 pass
52
53
54class MastodonBadGatewayError(MastodonServerError):
55 """Raised if the Server returns a 502 error"""
56 pass
57
58
59class MastodonServiceUnavailableError(MastodonServerError):
60 """Raised if the Server returns a 503 error"""
61 pass
62
63
64class MastodonGatewayTimeoutError(MastodonServerError):
65 """Raised if the Server returns a 504 error"""
66 pass
67
68
69class MastodonNotFoundError(MastodonAPIError):
70 """Raised when the Mastodon API returns a 404 Not Found error"""
71 pass
72
73
74class MastodonUnauthorizedError(MastodonAPIError):
75 """Raised when the Mastodon API returns a 401 Unauthorized error
76
77 This happens when an OAuth token is invalid or has been revoked,
78 or when trying to access an endpoint that can't be used without
79 authentication without providing credentials."""
80 pass
81
82
83class MastodonRatelimitError(MastodonError):
84 """Raised when rate limiting is set to manual mode and the rate limit is exceeded"""
85 pass
86
87
88class MastodonMalformedEventError(MastodonError):
89 """Raised when the server-sent event stream is malformed"""
90 pass
Powered by cgit v1.2.3 (git 2.41.0)