From 7f9330d184e408bdaed68f1015d53f9916168fe7 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 25 Oct 2019 13:48:14 +0200 Subject: [PATCH] Send dice error messages --- royalnet/packs/rpg/commands/dice.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/royalnet/packs/rpg/commands/dice.py b/royalnet/packs/rpg/commands/dice.py index 632d05ab..f75d8388 100644 --- a/royalnet/packs/rpg/commands/dice.py +++ b/royalnet/packs/rpg/commands/dice.py @@ -13,7 +13,14 @@ class DiceCommand(Command): async def run(self, args: CommandArgs, data: CommandData) -> None: dice_str = args.joined(require_at_least=1) - roll = dice.roll(dice_str) + try: + roll = dice.roll(dice_str) + except dice.DiceFatalException as e: + raise CommandError(e.msg) + except dice.DiceException as e: + raise CommandError(e.msg) + except dice.DiceBaseException as e: + raise CommandError(str(e)) try: result = list(roll) except TypeError: