Remove generic exceptions

This commit is contained in:
PapaTutuWawa 2025-04-21 14:24:13 +02:00
parent 969921dd79
commit f55542cf18
2 changed files with 13 additions and 4 deletions

View File

@ -6,3 +6,13 @@ class ConfigurationException(Exception):
def __init__(self, msg: str):
super().__init__(msg)
class UnknownConstraintException(Exception):
"""
Exception that is raised when there is a constraint type
that we do not know about.
"""
def __init__(self, msg: str):
super().__init__(msg)

View File

@ -1,5 +1,6 @@
import xmpp_api.api.types.v1.bot as bot_api
import xmpp_api.db.bot as bot_db
from xmpp_api.exceptions.base import UnknownConstraintException
def bot_constraint_to_db(constraint: bot_api.BotConstraint) -> bot_db.BotConstraint:
@ -9,8 +10,7 @@ def bot_constraint_to_db(constraint: bot_api.BotConstraint) -> bot_db.BotConstra
domains=constraint.domains,
)
case _:
# TODO: Proper exception type
raise Exception()
raise UnknownConstraintException(constraint.__class__.__name__)
def bot_constraint_from_db(constraint: bot_db.BotConstraint) -> bot_api.BotConstraint:
@ -20,5 +20,4 @@ def bot_constraint_from_db(constraint: bot_db.BotConstraint) -> bot_api.BotConst
domains=constraint.domains,
)
case _:
# TODO: Proper exception type
raise Exception()
raise UnknownConstraintException(constraint.__class__.__name__)