aboutsummaryrefslogtreecommitdiffstats
path: root/bot/utils/exceptions.py
diff options
context:
space:
mode:
authorGravatar Xithrius <[email protected]>2021-08-23 02:07:03 -0700
committerGravatar GitHub <[email protected]>2021-08-23 02:07:03 -0700
commit0a1b7b4bedbb6c19ad572869b57b466adae66b4a (patch)
tree73d1b3d2a2c82733b4e0ec642249b6a0f0f96d2e /bot/utils/exceptions.py
parentMerge pull request #813 from python-discord/avatar-effects-fix (diff)
parentMerge branch 'main' into pr/wikipediaissue (diff)
Merge pull request #795 from D0rs4n/pr/wikipediaissue
Handle Wikipedia API errors and warnings in the Wikipedia Cog
Diffstat (limited to 'bot/utils/exceptions.py')
-rw-r--r--bot/utils/exceptions.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/bot/utils/exceptions.py b/bot/utils/exceptions.py
index 9e080759..bf0e5813 100644
--- a/bot/utils/exceptions.py
+++ b/bot/utils/exceptions.py
@@ -1,4 +1,17 @@
+from typing import Optional
+
+
class UserNotPlayingError(Exception):
"""Raised when users try to use game commands when they are not playing."""
pass
+
+
+class APIError(Exception):
+ """Raised when an external API (eg. Wikipedia) returns an error response."""
+
+ def __init__(self, api: str, status_code: int, error_msg: Optional[str] = None):
+ super().__init__()
+ self.api = api
+ self.status_code = status_code
+ self.error_msg = error_msg