12345678910111213141516 |
- from functools import wraps
- from ..types import Message, Context, Response, CommandType
- from ..failure import RollbotFailureException
- def with_failure_handling(fn: CommandType) -> CommandType:
- @wraps(fn)
- async def wrapped(message: Message, context: Context):
- try:
- await fn()
- except RollbotFailureException as exc:
- # TODO handle errors more specifically
- await context.respond(Response.from_message(message, str(exc.failure)))
- return wrapped
|