diff --git a/src/xmpp_api/exceptions/base.py b/src/xmpp_api/exceptions/base.py index fbebae8..7083dc8 100644 --- a/src/xmpp_api/exceptions/base.py +++ b/src/xmpp_api/exceptions/base.py @@ -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) diff --git a/src/xmpp_api/util/constraints.py b/src/xmpp_api/util/constraints.py index 093ae08..010289c 100644 --- a/src/xmpp_api/util/constraints.py +++ b/src/xmpp_api/util/constraints.py @@ -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__)