Added more custom exceptions and prepared everything for documentation

This commit is contained in:
2025-04-27 12:39:30 +02:00
parent 6b143d8a2d
commit 638658af75
10 changed files with 146 additions and 53 deletions

View File

@@ -0,0 +1,20 @@
from typing import Optional
from bson import ObjectId
class EventNotFoundError(Exception):
"""PycordEvent could not find event with such an ID in the database"""
def __init__(self, event_id: Optional[str | ObjectId] = None, event_name: Optional[str] = None) -> None:
self.event_id = event_id
self.event_name = event_name
if self.event_id is None and self.event_name is None:
raise AttributeError("Either event id or name must be provided")
super().__init__(
f"Event with id {self.event_id} was not found"
if event_id is not None
else f"Event with name {self.event_name} was not found"
)