Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions arthur/apis/github/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .teams import GitHubException, add_staff_member
from .teams import GitHubError, add_staff_member

__all__ = ("GitHubException", "add_staff_member")
__all__ = ("GitHubError", "add_staff_member")
10 changes: 5 additions & 5 deletions arthur/apis/github/teams.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
HTTP_422 = 422


class GitHubException(Exception):
class GitHubError(Exception):
"""Custom exception for GitHub API errors."""

def __init__(self, message: str):
Expand All @@ -31,13 +31,13 @@ async def add_staff_member(username: str) -> None:
except aiohttp.ClientResponseError as e:
if e.status == HTTP_404:
msg = f"Team or user not found: {e.message}"
raise GitHubException(msg)
raise GitHubError(msg)
if e.status == HTTP_403:
msg = f"Forbidden: {e.message}"
raise GitHubException(msg)
raise GitHubError(msg)
if e.status == HTTP_422:
msg = "Cannot add organisation as a team member"
raise GitHubException(msg)
raise GitHubError(msg)

msg = f"Unexpected error: {e.message}"
raise GitHubException(msg)
raise GitHubError(msg)
4 changes: 2 additions & 2 deletions arthur/exts/github/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from discord.ext.commands import Cog, Context, group

from arthur.apis.github import GitHubException, add_staff_member
from arthur.apis.github import GitHubError, add_staff_member
from arthur.bot import KingArthur
from arthur.config import CONFIG

Expand Down Expand Up @@ -33,7 +33,7 @@ async def add_team_member(self, ctx: Context, username: str) -> None:
try:
await add_staff_member(username)
await ctx.send(f":white_check_mark: Successfully invited {username} to the staff team.")
except GitHubException as e:
except GitHubError as e:
await ctx.send(f":x: Failed to add {username} to the staff team: {e}")


Expand Down