json: improve 'bad input' error message (#2420)

When 'read-json' finds "bad input", print the input to try to show what
went wrong.
This commit is contained in:
Ben Greenman 2018-12-08 16:31:58 -05:00 committed by Matthias Felleisen
parent a66038a427
commit 0c2ada98ff

View File

@ -248,7 +248,7 @@
(cond [(equal? m #"\"") (read-string)]
[(equal? m #"[") (read-list 'array #rx#"^\\]" read-json)]
[(equal? m #"{") (read-hash)])))]
[else (err "bad input")]))
[else (err (format "bad input~n ~e" (peek-bytes (sub1 (error-print-width)) 0 i)))]))
;;
(read-json #t))