Catch ValueError from utils.parse_number, to allow other code to deal with
complaining about invalid numbers
This commit is contained in:
parent
40ffb6ce0e
commit
54ba3c888c
1 changed files with 8 additions and 2 deletions
|
@ -208,7 +208,10 @@ class Module(ModuleManager.BaseModule):
|
||||||
event["user"].nickname)
|
event["user"].nickname)
|
||||||
return
|
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)
|
match = REGEX_FLOAT.match(coin_bet)
|
||||||
if not match or round(decimal.Decimal(coin_bet), 2) <= DECIMAL_ZERO:
|
if not match or round(decimal.Decimal(coin_bet), 2) <= DECIMAL_ZERO:
|
||||||
event["stderr"].write("%s: Please provide a number of coins to bet"
|
event["stderr"].write("%s: Please provide a number of coins to bet"
|
||||||
|
@ -333,7 +336,10 @@ class Module(ModuleManager.BaseModule):
|
||||||
return
|
return
|
||||||
|
|
||||||
for i, bet_amount in enumerate(bet_amounts):
|
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)
|
match = REGEX_FLOAT.match(bet_amount)
|
||||||
if not match or round(decimal.Decimal(bet_amount), 2
|
if not match or round(decimal.Decimal(bet_amount), 2
|
||||||
) <= DECIMAL_ZERO:
|
) <= DECIMAL_ZERO:
|
||||||
|
|
Loading…
Reference in a new issue