GloryBot/classes/errors/check.py

59 lines
1.9 KiB
Python
Raw Normal View History

2024-06-02 22:51:07 +03:00
from bson import ObjectId
class CheckNotFoundError(Exception):
"""Exception raised when check does not exist in a database.
### Attributes:
* guild (`ObjectId`): Member's guild.
* member (`ObjectId`): Member ID.
"""
def __init__(self, guild: ObjectId, member: ObjectId):
self.guild: ObjectId = guild
self.member: ObjectId = member
super().__init__(
f"Could not find a check for member {str(member)} in the guild with id {str(guild)}."
)
def __str__(self):
return f"Could not find a check for member {str(self.member)} in the guild with id {str(self.guild)}."
class CheckAlreadyAssignedError(Exception):
"""Exception raised when a member already has an active check on their record.
### Attributes:
* guild (`ObjectId`): Member's guild.
* member (`ObjectId`): Member ID.
"""
def __init__(self, guild: ObjectId, member: ObjectId):
self.guild: ObjectId = guild
self.member: ObjectId = member
super().__init__(
f"Member {str(member)} in the guild with id {str(guild)} already has an active check on record."
)
def __str__(self):
return f"Member {str(self.member)} in the guild with id {str(self.guild)} already has an active check on record."
class CheckChallengeNotFoundError(Exception):
"""Exception raised when challenge of the check cannot be found in a database.
### Attributes:
* check (`ObjectId`): Check's ID.
* challenge (`ObjectId`): Challenge's ID.
"""
def __init__(self, check: ObjectId, challenge: ObjectId):
self.check: ObjectId = check
self.challenge: ObjectId = challenge
super().__init__(
f"Challenge {str(challenge)} of the check {str(check)} could not be found."
)
def __str__(self):
return f"Challenge {str(self.challenge)} of the check {str(self.check)} could not be found."