-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.py
More file actions
40 lines (33 loc) · 1.23 KB
/
errors.py
File metadata and controls
40 lines (33 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
Define custom to-do related error classes which are more descriptive than simply ValueError
"""
class TodoError(Exception):
"""
Base class from which all other errors are derived.
Multiple different derived errors can be caught with one except TodoError statement.
"""
pass
class TaskNotFoundError(TodoError):
"""
Raised when task requested by user is not in the current tasklist.
"""
def __init__(self, task_name):
self.task_name = task_name
self.error_message = f"Aufgabe {self.task_name} nicht gefunden."
super().__init__(self.error_message)
class DuplicateTaskError(TodoError):
"""
Raised when task requested by user is already in the current tasklist.
"""
def __init__(self, task_name):
self.task_name = task_name
self.error_message = f"Aufgabe {self.task_name} bereits in To-Do Liste enthalten."
super().__init__(self.error_message)
class TaskAlreadyDoneError(TodoError):
"""
Raised when task passed to mark_done by user is already done.
"""
def __init__(self, task_name):
self.task_name = task_name
self.error_message = f"Aufgabe {self.task_name} bereits erledigt."
super().__init__(self.error_message)