blob: c0cc0550beb5a783d79d5fd70d87b346f43259d1 (
plain)
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
|
"""Defines a few application-specific exceptions for Pythonic code."""
class UmbrellaNotFoundError(Exception):
"""For when an umbrella with required serial is not found in database."""
def __init__(self, serial):
self.serial = serial
self.message = f"No umbrella {serial} found."
super().__init__(self.message)
class UmbrellaStatusError(Exception):
"""For when the umbrella to be lent is not available, or when an umbrella to be returned has
never been taken away. Most likely duplicate or erroneous answer sheets submitted by user.
"""
pass
class UmbrellaValueError(Exception):
"""For when an admin enters an invalid value when modifying the database."""
def __init__(self, field: str):
self.field = field
self.message = f"Invalid field: {field}."
super().__init__(self.message)
class UsernameTakenError(Exception):
"""For when a username to be registered with is already taken."""
def __init__(self, username: str):
self.username = username
self.message = f"Username {username} is already taken."
super().__init__(self.message)
|