-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexceptions.py
More file actions
29 lines (17 loc) · 920 Bytes
/
exceptions.py
File metadata and controls
29 lines (17 loc) · 920 Bytes
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
"""Exceptions raised when user provides an input."""
class QuitCommand(Exception):
"""Exception raised when the quit command is detected."""
def __init__(self, message: str = "Exiting Program..."):
super().__init__(message)
class InvalidInputError(Exception):
"""Exception raised when the user gives an invalid input."""
def __init__(self, message: str = "Invalid input. Please try again."):
super().__init__(message)
class InvalidLengthError(InvalidInputError):
"""Exception raised when the user gives invalid length of input."""
def __init__(self, message: str = "Invalid length. Please try again."):
super().__init__(message)
class InvalidTypeError(InvalidInputError):
"""Exception raised when the user gives invalid type of input."""
def __init__(self, message: str = "Only integers accepted. Please try again."):
super().__init__(message)