Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raise exception instead of log an error #150

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
raise exception instead of log an error
  • Loading branch information
jordanst3wart committed Mar 6, 2024
commit b639fdae22d392904263237e07395e2c909f28b4
4 changes: 2 additions & 2 deletions discord_webhook/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import Any, Dict, List, Optional, Tuple, Union
import requests

from .webhook_exceptions import ColorNotInRangeException
from .webhook_exceptions import ColorNotInRangeException, DiscordException

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -448,7 +448,7 @@ def execute(self, remove_embeds: bool = False) -> "requests.Response":
response = self.handle_rate_limit(response, self.api_post_request)
logger.debug("Webhook executed")
else:
logger.error(
raise DiscordException(
"Webhook status code {status_code}: {content}".format(
status_code=response.status_code,
content=response.content.decode("utf-8"),
Expand Down
9 changes: 9 additions & 0 deletions discord_webhook/webhook_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,12 @@ def __init__(self, color: Union[str, int], message=None) -> None:
" (HEXADECIMAL)."
)
super().__init__(message)

class DiscordException(Exception):
"""
This Exception is throw as a generic error from discord's API.
"""

def __init__(self, *args: object) -> None:
super().__init__(*args)