diff options
author | Elizabeth Myers <[email protected]> | 2017-09-25 19:05:12 -0500 |
---|---|---|
committer | Elizabeth Myers <[email protected]> | 2017-09-25 19:11:16 -0500 |
commit | c64617ee9474d8690df1e395f8454f02a0ddae6c (patch) | |
tree | 390cfd966da48c08dae404889180303be5f93429 /mastodon | |
parent | 6ab283d17e1eac2b521bbaffc1b0a635fd68c9f5 (diff) | |
download | mastodon.py-c64617ee9474d8690df1e395f8454f02a0ddae6c.tar.gz |
Redesign exception hierarchy
All Mastodon.py errors now derive from MastodonError, for easier
catching in application code that just wants to see if something
happened, and isn't too miffed about the details.
I/O Errors derive from MastodonIOError, for similar reasons.
This change is designed to be backwards compatible.
Diffstat (limited to 'mastodon')
-rw-r--r-- | mastodon/Mastodon.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 49db771..8634fd1 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py | |||
@@ -1280,21 +1280,29 @@ class Mastodon: | |||
1280 | ## | 1280 | ## |
1281 | # Exceptions | 1281 | # Exceptions |
1282 | ## | 1282 | ## |
1283 | class MastodonIllegalArgumentError(ValueError): | 1283 | class MastodonError(Exception): |
1284 | """Base class for Mastodon.py exceptions""" | ||
1285 | |||
1286 | |||
1287 | class MastodonIllegalArgumentError(ValueError, MastodonError): | ||
1284 | pass | 1288 | pass |
1285 | 1289 | ||
1286 | 1290 | ||
1287 | class MastodonFileNotFoundError(IOError): | 1291 | class MastodonIOError(IOError, MastodonError): |
1292 | """Base class for Mastodon.py I/O errors""" | ||
1293 | |||
1294 | |||
1295 | class MastodonFileNotFoundError(MastodonIOError): | ||
1288 | pass | 1296 | pass |
1289 | 1297 | ||
1290 | 1298 | ||
1291 | class MastodonNetworkError(IOError): | 1299 | class MastodonNetworkError(MastodonIOError): |
1292 | pass | 1300 | pass |
1293 | 1301 | ||
1294 | 1302 | ||
1295 | class MastodonAPIError(Exception): | 1303 | class MastodonAPIError(MastodonError): |
1296 | pass | 1304 | pass |
1297 | 1305 | ||
1298 | 1306 | ||
1299 | class MastodonRatelimitError(Exception): | 1307 | class MastodonRatelimitError(MastodonError): |
1300 | pass | 1308 | pass |