Commit b29e0c06 authored by Jérome Perrin's avatar Jérome Perrin

format-json: display filename and error location on error

parent 5c417099
...@@ -25,7 +25,7 @@ def main(): ...@@ -25,7 +25,7 @@ def main():
obj = json.load(infile, object_pairs_hook=collections.OrderedDict) obj = json.load(infile, object_pairs_hook=collections.OrderedDict)
except ValueError as e: except ValueError as e:
exit_code = 1 exit_code = 1
print(e, file=sys.stderr) print(f'{f}:{e.lineno}', e, file=sys.stderr)
else: else:
with open(f, 'w') as outfile: with open(f, 'w') as outfile:
json.dump(obj, outfile, ensure_ascii=False, sort_keys=False, indent=2, separators=(',', ': ')) json.dump(obj, outfile, ensure_ascii=False, sort_keys=False, indent=2, separators=(',', ': '))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment