From 85e5951799869074b43714ef02aa0c972c9b15cb Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Thu, 10 Jul 2025 14:52:57 +0100 Subject: Fix mistakes from my inferior brain (#327) * Rename GitHubException in cog * Update GitHubException in Teams API * Update __init__.py in GitHub API with new exception naming --- arthur/apis/github/__init__.py | 4 ++-- arthur/apis/github/teams.py | 10 +++++----- arthur/exts/github/management.py | 4 ++-- 3 files changed, 9 insertions(+), 9 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") 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_403 = 403 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) 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 @@ class GitHubManagement(Cog): 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}") -- cgit v1.2.3