From 93d6ea403c1874bb3377553c8cc181273446bded Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Thu, 10 Jul 2025 14:39:54 +0100 Subject: [PATCH 1/3] Rename GitHubException in cog --- arthur/exts/github/management.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arthur/exts/github/management.py b/arthur/exts/github/management.py index 202dd5b..ee3dca3 100644 --- a/arthur/exts/github/management.py +++ b/arthur/exts/github/management.py @@ -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 @@ -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}") From 601688dc27886307e015af5543a86738f756be31 Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Thu, 10 Jul 2025 14:40:48 +0100 Subject: [PATCH 2/3] Update GitHubException in Teams API --- arthur/apis/github/teams.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arthur/apis/github/teams.py b/arthur/apis/github/teams.py index 5fcc3a0..489da90 100644 --- a/arthur/apis/github/teams.py +++ b/arthur/apis/github/teams.py @@ -13,7 +13,7 @@ HTTP_422 = 422 -class GitHubException(Exception): +class GitHubError(Exception): """Custom exception for GitHub API errors.""" def __init__(self, message: str): @@ -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) From 4b139fde951614b4d6a26900a65fd971a8df297a Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Thu, 10 Jul 2025 14:41:13 +0100 Subject: [PATCH 3/3] Update __init__.py in GitHub API with new exception naming --- arthur/apis/github/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arthur/apis/github/__init__.py b/arthur/apis/github/__init__.py index 468bbe6..11261da 100644 --- a/arthur/apis/github/__init__.py +++ b/arthur/apis/github/__init__.py @@ -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")