Fix exc. raising logic to match validation issues

This commit is contained in:
Sander Maijers
2016-06-13 11:34:55 +02:00
parent a5628863e8
commit abaf0d12de

View File

@ -28,19 +28,20 @@ def parse_indent(s):
# type: (str) -> str
try:
int_indentation_spec = int(s)
except ValueError:
if not s.strip():
return s
else:
raise ValueError(
'Non-whitespace JSON indentation delimiter supplied. ',
)
else:
if int_indentation_spec >= 0:
return int_indentation_spec * ' '
else:
raise ValueError(
'Negative integer supplied to construct JSON indentation delimiter. ',
)
except ValueError:
if s.strip() == '':
return s
else:
raise ValueError(
'Non-whitespace JSON indentation delimiter supplied. ',
)
def pretty_format_json(argv=None):