diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2016-06-25 05:51:26 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2016-06-25 05:51:26 +0300 |
commit | 20add003b16bdbaba279ef6286a0f0025658d1e2 (patch) | |
tree | c73888320c21d9213babe6e4ef87d73ee25e1dd5 /test.py | |
parent | sort algorithms in usage messages (diff) | |
download | sorting-algorithms-20add003b16bdbaba279ef6286a0f0025658d1e2.tar.gz sorting-algorithms-20add003b16bdbaba279ef6286a0f0025658d1e2.zip |
improve command line parsing errors
Diffstat (limited to '')
-rw-r--r-- | test.py | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -22,9 +22,12 @@ def test(algorithm, input_kind=_DEFAULT_INPUT_KIND, length=_DEFAULT_LENGTH): print(output) def _parse_natural_number(s): - n = int(s) + try: + n = int(s) + except ValueError: + raise argparse.ArgumentTypeError('must be a non-negative integer: ' + str(s)) if n < 0: - raise argparse.ArgumentTypeError('must not be a negative number') + raise argparse.ArgumentTypeError('must be a non-negative integer') return n def _parse_input_kind(s): |