From 190dce6f5dfe8c3955ee9fc0406537965bc49d32 Mon Sep 17 00:00:00 2001 From: Paillat Date: Thu, 13 Mar 2025 09:23:56 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Refactor=20error=20handling=20by=20?= =?UTF-8?q?moving=20errors=20to=20a=20new=20file=20(#9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * :sparkles: Refactor error handling by moving errors to a new file --- src/pycord_rest/app.py | 9 +-------- src/pycord_rest/errors.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 src/pycord_rest/errors.py diff --git a/src/pycord_rest/app.py b/src/pycord_rest/app.py index 408bb6b..2507d32 100644 --- a/src/pycord_rest/app.py +++ b/src/pycord_rest/app.py @@ -16,6 +16,7 @@ from fastapi import APIRouter, Depends, FastAPI, HTTPException, Request, Respons from nacl.exceptions import BadSignatureError from nacl.signing import VerifyKey +from .errors import InvalidCredentialsError from .models import EventType, WebhookEventPayload, WebhookType logger = logging.getLogger("pycord.rest") @@ -36,14 +37,6 @@ class ApplicationAuthorizedEvent: ) -class PycordRestError(discord.DiscordException): - pass - - -class InvalidCredentialsError(PycordRestError): - pass - - def not_supported[T, U](func: Callable[[T], U]) -> Callable[[T], U]: @functools.wraps(func) def inner(*args: T, **kwargs: T) -> U: diff --git a/src/pycord_rest/errors.py b/src/pycord_rest/errors.py new file mode 100644 index 0000000..9ceec6b --- /dev/null +++ b/src/pycord_rest/errors.py @@ -0,0 +1,12 @@ +# Copyright (c) Paillat-dev +# SPDX-License-Identifier: MIT + +import discord + + +class PycordRestError(discord.DiscordException): + pass + + +class InvalidCredentialsError(PycordRestError): + pass