This is an automated email from the ASF dual-hosted git repository. gstein pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/steve.git
commit 1aaf62b85d48f630b048297b32725e7382bd5bbe Author: Greg Stein <[email protected]> AuthorDate: Mon Oct 13 02:09:34 2025 -0500 Add PersonNotFound exception. --- v3/steve/persondb.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/v3/steve/persondb.py b/v3/steve/persondb.py index 160fc57..34b4a56 100644 --- a/v3/steve/persondb.py +++ b/v3/steve/persondb.py @@ -42,6 +42,9 @@ class PersonDB: # NEVER return person.salt person = self.q_get_person.first_row(pid) + if not person: + raise PersonNotFound(pid) + return person.name, person.email def add_person(self, pid, name, email): @@ -62,6 +65,11 @@ class PersonDB: self.c_delete_person.perform(pid) + # If the Person didn't exist, we deleted nothing. + if self.c_delete_person.rowcount == 0: + raise PersonNotFound(pid) + # else .rowcount == 1 + def list_persons(self): "Return ordered EasyDict<PID, NAME, EMAIL> for each Person." @@ -70,3 +78,12 @@ class PersonDB: # Run the query to completion, and return the entire list of Persons. self.q_person.perform() return list(self.q_person.fetchall()) # asfpy.db.DB uses EasyDict + + +class PersonNotFound(Exception): + def __init__(self, pid): + self.pid = pid + super().__init__(str(self)) + + def __str__(self): + return f'Person[P:{self.pid}] not found'
