diff options
| author | 2018-10-14 15:27:49 +0100 | |
|---|---|---|
| committer | 2018-10-14 15:27:49 +0100 | |
| commit | 54ba3c888c25c5a827838a308f73a2a73ccd6bf1 (patch) | |
| tree | ec8fcd6d20b0272e07e4789e2b3289dfc9b68c47 /modules | |
| parent | Typo in src/IRCServer.py, 'defau;t' -> 'default' (diff) | |
Catch ValueError from utils.parse_number, to allow other code to deal with
complaining about invalid numbers
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/coins.py | 10 |
1 files 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: |
