decoder now catches function clause errors and converts them to {error, badjson} tuples

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

View file

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