From c64617ee9474d8690df1e395f8454f02a0ddae6c Mon Sep 17 00:00:00 2001 From: Elizabeth Myers Date: Mon, 25 Sep 2017 19:05:12 -0500 Subject: 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. --- mastodon/Mastodon.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'mastodon') 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: ## # Exceptions ## -class MastodonIllegalArgumentError(ValueError): +class MastodonError(Exception): + """Base class for Mastodon.py exceptions""" + + +class MastodonIllegalArgumentError(ValueError, MastodonError): pass -class MastodonFileNotFoundError(IOError): +class MastodonIOError(IOError, MastodonError): + """Base class for Mastodon.py I/O errors""" + + +class MastodonFileNotFoundError(MastodonIOError): pass -class MastodonNetworkError(IOError): +class MastodonNetworkError(MastodonIOError): pass -class MastodonAPIError(Exception): +class MastodonAPIError(MastodonError): pass -class MastodonRatelimitError(Exception): +class MastodonRatelimitError(MastodonError): pass -- cgit v1.2.3