diff options
Diffstat (limited to 'bot/utils')
-rw-r--r-- | bot/utils/exceptions.py | 13 | ||||
-rw-r--r-- | bot/utils/pagination.py | 6 |
2 files changed, 16 insertions, 3 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 diff --git a/bot/utils/pagination.py b/bot/utils/pagination.py index d9c0862a..b1062c09 100644 --- a/bot/utils/pagination.py +++ b/bot/utils/pagination.py @@ -20,7 +20,7 @@ PAGINATION_EMOJI = (FIRST_EMOJI, LEFT_EMOJI, RIGHT_EMOJI, LAST_EMOJI, DELETE_EMO log = logging.getLogger(__name__) -class EmptyPaginatorEmbed(Exception): +class EmptyPaginatorEmbedError(Exception): """Base Exception class for an empty paginator embed.""" @@ -141,7 +141,7 @@ class LinePaginator(Paginator): if not lines: if exception_on_empty_embed: log.exception("Pagination asked for empty lines iterable") - raise EmptyPaginatorEmbed("No lines to paginate") + raise EmptyPaginatorEmbedError("No lines to paginate") log.debug("No lines to add to paginator, adding '(nothing to display)' message") lines.append("(nothing to display)") @@ -349,7 +349,7 @@ class ImagePaginator(Paginator): if not pages: if exception_on_empty_embed: log.exception("Pagination asked for empty image list") - raise EmptyPaginatorEmbed("No images to paginate") + raise EmptyPaginatorEmbedError("No images to paginate") log.debug("No images to add to paginator, adding '(no images to display)' message") pages.append(("(no images to display)", "")) |