correctly catch and convert badjson errors

This commit is contained in:
alisdair sullivan 2010-05-30 16:30:32 -07:00
parent ac518dfe4a
commit 2bc885f3c4

View file

@ -101,7 +101,7 @@ decoder({{Mod, Fun}, State}, OptsList) when is_list(OptsList), is_atom(Mod), is_
Opts = parse_opts(OptsList),
decoder({fun(E, S) -> Mod:Fun(E, S) end, State}, Opts);
decoder(Callbacks, Opts) ->
fun(Stream) -> try start(Stream, [], Callbacks, Opts) catch error:function_clause -> {error, badjson} end end.
fun(Stream) -> try start(Stream, [], Callbacks, Opts) catch error:function_clause -> {error, badjson} ;error:badjson -> {error, badjson} end end.
parse_opts(Opts) ->