diff options
author | Frederick Yin <fkfd@fkfd.me> | 2021-10-27 11:20:27 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@fkfd.me> | 2021-10-27 11:20:27 +0800 |
commit | 3fdc1d0b91cf4be7768e940cf930e74005768177 (patch) | |
tree | 31eec01b95a200f8f32e44eb7e6fd566c538fde4 /jimbrella/exceptions.py | |
parent | 2a5870f529b5defe9154834c252b0d30cccc9c8d (diff) |
Provide exception messages
UmbrellaNotFoundError: serial
UmbrellaValueError: field
Diffstat (limited to 'jimbrella/exceptions.py')
-rw-r--r-- | jimbrella/exceptions.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/jimbrella/exceptions.py b/jimbrella/exceptions.py index 2c62bc4..ad92b50 100644 --- a/jimbrella/exceptions.py +++ b/jimbrella/exceptions.py @@ -4,7 +4,10 @@ class UmbrellaNotFoundError(Exception): """For when an umbrella with required serial is not found in database.""" - pass + def __init__(self, serial): + self.serial = serial + self.message = f"No umbrella {serial} found." + super().__init__(self.message) class UmbrellaStatusError(Exception): @@ -18,4 +21,7 @@ class UmbrellaStatusError(Exception): class UmbrellaValueError(Exception): """For when an admin enters an invalid value when modifying the database.""" - pass + def __init__(self, field: str): + self.field = field + self.message = f"Invalid field: {field}." + super().__init__(self.message) |