Added more custom exceptions and prepared everything for documentation
This commit is contained in:
20
classes/errors/pycord_event.py
Normal file
20
classes/errors/pycord_event.py
Normal 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"
|
||||
)
|
Reference in New Issue
Block a user