From 3fdc1d0b91cf4be7768e940cf930e74005768177 Mon Sep 17 00:00:00 2001 From: Frederick Yin Date: Wed, 27 Oct 2021 11:20:27 +0800 Subject: Provide exception messages UmbrellaNotFoundError: serial UmbrellaValueError: field --- jimbrella/exceptions.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'jimbrella/exceptions.py') 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) -- cgit v1.2.3