Better error messages on decoding invalid JSON. Changes the CouchDB version of mochijson2. Closes COUCHDB-258
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@745401 13f79535-47bb-0310-9956-ffa450edef68 Project: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/commit/4271c932 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/tree/4271c932 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/diff/4271c932 Branch: refs/heads/import-master Commit: 4271c932b4e7f53cde010e5bb2147fa3bc1ea7f9 Parents: d243ea3 Author: John Christopher Anderson <jch...@apache.org> Authored: Wed Feb 18 07:47:57 2009 +0000 Committer: John Christopher Anderson <jch...@apache.org> Committed: Wed Feb 18 07:47:57 2009 +0000 ---------------------------------------------------------------------- mochijson2.erl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/blob/4271c932/mochijson2.erl ---------------------------------------------------------------------- diff --git a/mochijson2.erl b/mochijson2.erl index 668486f..9b59c7d 100644 --- a/mochijson2.erl +++ b/mochijson2.erl @@ -70,7 +70,10 @@ decoder(Options) -> %% @spec decode(iolist()) -> json_term() %% @doc Decode the given iolist to Erlang terms. decode(S) -> - json_decode(S, #decoder{}). + try json_decode(S, #decoder{}) + catch + _:_ -> throw({invalid_json, S}) + end. test() -> test_all().