summaryrefslogtreecommitdiff
path: root/src/mochiweb
diff options
context:
space:
mode:
authorJohn Christopher Anderson <jchris@apache.org>2009-02-18 07:47:57 +0000
committerJohn Christopher Anderson <jchris@apache.org>2009-02-18 07:47:57 +0000
commitd778d2a96042dc06432c6abaea7da871b4dd4142 (patch)
treec3465d350672397c0eda04418543335a65561d59 /src/mochiweb
parent3b431fc0b30c5fb110afd06347058727724f0fb2 (diff)
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
Diffstat (limited to 'src/mochiweb')
-rw-r--r--src/mochiweb/mochijson2.erl5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/mochiweb/mochijson2.erl b/src/mochiweb/mochijson2.erl
index 668486fc..9b59c7df 100644
--- a/src/mochiweb/mochijson2.erl
+++ b/src/mochiweb/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().