From 54ba3c888c25c5a827838a308f73a2a73ccd6bf1 Mon Sep 17 00:00:00 2001 From: jesopo Date: Sun, 14 Oct 2018 15:27:49 +0100 Subject: [PATCH] Catch ValueError from utils.parse_number, to allow other code to deal with complaining about invalid numbers --- modules/coins.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/coins.py b/modules/coins.py index 7feaad77..e4f447f4 100644 --- a/modules/coins.py +++ b/modules/coins.py @@ -208,7 +208,10 @@ class Module(ModuleManager.BaseModule): event["user"].nickname) return - coin_bet = utils.parse_number(coin_bet) + try: + coin_bet = utils.parse_number(coin_bet) + except ValueError: + pass match = REGEX_FLOAT.match(coin_bet) if not match or round(decimal.Decimal(coin_bet), 2) <= DECIMAL_ZERO: event["stderr"].write("%s: Please provide a number of coins to bet" @@ -333,7 +336,10 @@ class Module(ModuleManager.BaseModule): return for i, bet_amount in enumerate(bet_amounts): - bet_amount = utils.parse_number(bet_amount) + try: + bet_amount = utils.parse_number(bet_amount) + except ValueError: + pass match = REGEX_FLOAT.match(bet_amount) if not match or round(decimal.Decimal(bet_amount), 2 ) <= DECIMAL_ZERO: