diff options
Diffstat (limited to 'jimbrella/database.py')
-rw-r--r-- | jimbrella/database.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/jimbrella/database.py b/jimbrella/database.py index 014b5b5..63cba49 100644 --- a/jimbrella/database.py +++ b/jimbrella/database.py @@ -3,6 +3,7 @@ import os from datetime import datetime, timedelta from .utils import human_datetime, human_timedelta from .config import DUE_HOURS +from .exceptions import * class Database: @@ -201,9 +202,9 @@ class Database: """When a user has borrowed an umbrella.""" umb = self._find_by_serial(serial) if umb is None: - raise ValueError(f"No umbrella with serial {serial} found.") + raise UmbrellaNotFoundError elif umb["status"] != "available": - raise ValueError(f"Umbrella with serial {serial} is inavailable.") + raise UmbrellaStatusError umb["status"] = "lent" umb["tenant_name"] = tenant_name umb["tenant_id"] = tenant_id @@ -216,9 +217,9 @@ class Database: """When a user has returned an umbrella.""" umb = self._find_by_serial(serial) if umb is None: - raise ValueError(f"No umbrella with serial {serial} found.") + raise UmbrellaNotFoundError elif umb["status"] not in ("lent", "overdue"): - raise ValueError(f"Umbrella with serial {serial} is not lent out.") + raise UmbrellaStatusError umb["status"] = "available" for key in ["tenant_name", "tenant_id", "tenant_phone", "tenant_email"]: umb[key] = "" |