Merge pull request #97 from ualvesdias/patch-1

Update check_positive method to handle ValueError exception.
This commit is contained in:
Michael Skelton
2020-03-12 07:24:56 +10:00
committed by GitHub

View File

@@ -24,9 +24,12 @@ class InputHelper(object):
@staticmethod
def check_positive(parser, arg):
ivalue = int(arg)
if ivalue <= 0:
raise parser.ArgumentTypeError("%s is not a valid positive integer!" % arg)
try:
ivalue = int(arg)
if ivalue <= 0:
raise parser.ArgumentTypeError("%s is not a valid positive integer!" % arg)
except ValueError as e:
raise parser.ArgumentValueError("%s is not a a number!" % arg)
return arg