Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions pokedex/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ def register_subscriber(self, email):
try:
self.__conn.execute("INSERT into SUBSCRIBERS(email) values (?)", (email,))
self.__conn.commit()
except sqlite3.DatabaseError:
raise Exception("Problem with the database!")
except sqlite3.IntegrityError:
raise ValueError("Email already exists!")
except sqlite3.DatabaseError:
raise RuntimeError("Problem with the database!")

def cleanup(self, should_close: bool):
if should_close:
Expand All @@ -33,6 +33,5 @@ def fetch_all_pokemons(wrapper: ConnectionWrapper):
def register_subscriber(wrapper: ConnectionWrapper, email):
pattern = re.compile(r"(.*)@(.*\..*)")
if not pattern.match(email):
ValueError("Invalid email!")
raise ValueError("Invalid email!")
wrapper.register_subscriber(email)
pass