Remove generic exceptions
This commit is contained in:
parent
969921dd79
commit
f55542cf18
@ -6,3 +6,13 @@ class ConfigurationException(Exception):
|
|||||||
|
|
||||||
def __init__(self, msg: str):
|
def __init__(self, msg: str):
|
||||||
super().__init__(msg)
|
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)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import xmpp_api.api.types.v1.bot as bot_api
|
import xmpp_api.api.types.v1.bot as bot_api
|
||||||
import xmpp_api.db.bot as bot_db
|
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:
|
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,
|
domains=constraint.domains,
|
||||||
)
|
)
|
||||||
case _:
|
case _:
|
||||||
# TODO: Proper exception type
|
raise UnknownConstraintException(constraint.__class__.__name__)
|
||||||
raise Exception()
|
|
||||||
|
|
||||||
|
|
||||||
def bot_constraint_from_db(constraint: bot_db.BotConstraint) -> bot_api.BotConstraint:
|
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,
|
domains=constraint.domains,
|
||||||
)
|
)
|
||||||
case _:
|
case _:
|
||||||
# TODO: Proper exception type
|
raise UnknownConstraintException(constraint.__class__.__name__)
|
||||||
raise Exception()
|
|
||||||
|
Loading…
Reference in New Issue
Block a user