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/database.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'jimbrella/database.py') diff --git a/jimbrella/database.py b/jimbrella/database.py index ab945da..e43b8f2 100644 --- a/jimbrella/database.py +++ b/jimbrella/database.py @@ -190,7 +190,7 @@ class Database: umb["serial"] = int(umb["serial"]) umb_in_db = self._find_by_serial(umb["serial"]) if umb_in_db is None: - raise UmbrellaNotFoundError + raise UmbrellaNotFoundError(umb["serial"]) status = umb_in_db["status"] if "status" in umb and umb["status"]: @@ -261,7 +261,7 @@ class Database: """When a user has borrowed an umbrella.""" umb = self._find_by_serial(serial) if umb is None: - raise UmbrellaNotFoundError + raise UmbrellaNotFoundError(serial) elif umb["status"] != "available": raise UmbrellaStatusError umb["status"] = "lent" @@ -276,7 +276,7 @@ class Database: """When a user has returned an umbrella.""" umb = self._find_by_serial(serial) if umb is None: - raise UmbrellaNotFoundError + raise UmbrellaNotFoundError(serial) elif umb["status"] not in ("lent", "overdue"): raise UmbrellaStatusError umb["status"] = "available" @@ -289,7 +289,7 @@ class Database: """When an umbrella is overdue, change its status to "overdue".""" umb = self._find_by_serial(serial) if umb is None: - raise UmbrellaNotFoundError + raise UmbrellaNotFoundError(serial) elif umb["status"] != "lent": raise UmbrellaStatusError umb["status"] = "overdue" -- cgit v1.2.3