From 5735dd0b55c6bf0e398d9f6ca78230871f36efab Mon Sep 17 00:00:00 2001 From: Arjun Satarkar Date: Mon, 12 Feb 2024 18:09:14 -0500 Subject: question_of_the_day: improve error handling in qotd approve command --- question_of_the_day/errors.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 question_of_the_day/errors.py (limited to 'question_of_the_day/errors.py') diff --git a/question_of_the_day/errors.py b/question_of_the_day/errors.py new file mode 100644 index 0000000..bc08ec8 --- /dev/null +++ b/question_of_the_day/errors.py @@ -0,0 +1,20 @@ +class NoSuchSuggestionError(Exception): + def __init__(self, suggestion_id: int): + self.suggestion_id = suggestion_id + + def __repr__(self): + return f"NoSuchSuggestionError({self.suggestion_id})" + + def __str__(self): + return f"Error: no suggestion with id {self.suggestion_id} found in suggestion queue." + + +class QuestionLimitReachedError(Exception): + def __init__(self, question_limit: int): + self.question_limit = question_limit + + def __repr__(self): + return f"QuestionLimitReachedError({self.question_limit})" + + def __str__(self): + return f"Error: there are already {self.question_limit} questions in the main queue; can't add more." -- cgit v1.2.3-57-g22cb