From b9d10181ab591104f73e93c53f05379aeb0d99d7 Mon Sep 17 00:00:00 2001 From: amtal Date: Thu, 23 Jun 2011 14:41:51 -0700 Subject: [PATCH] switched to error/2 from error/1 in exported funcs Passing a list of arguments in the second parameter, makes them show up in the stack trace in place of the function arity number. For referentially transparent functions (which foo_to_bar tend to be) failures can then be reproduced from just the stack trace! If using error/1, you must rely on some higher layer to add enough info to reproduce the crash. --- src/jsx.erl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/jsx.erl b/src/jsx.erl index 203175d..ecc0272 100644 --- a/src/jsx.erl +++ b/src/jsx.erl @@ -76,7 +76,7 @@ decoder(OptsList) -> json_to_term(JSON) -> try json_to_term(JSON, []) %% rethrow exception so internals aren't confusingly exposed to users - catch error:badarg -> erlang:error(badarg) + catch error:badarg -> erlang:error(badarg,[JSON]) end. @@ -91,7 +91,7 @@ json_to_term(JSON, Opts) -> term_to_json(JSON) -> try term_to_json(JSON, []) %% rethrow exception so internals aren't confusingly exposed to users - catch error:badarg -> erlang:error(badarg) + catch error:badarg -> erlang:error(badarg,[JSON]) end. @@ -100,7 +100,7 @@ term_to_json(JSON) -> term_to_json(JSON, Opts) -> try jsx_eep0018:term_to_json(JSON, Opts) %% rethrow exception so internals aren't confusingly exposed to users - catch error:badarg -> erlang:error(badarg) + catch error:badarg -> erlang:error(badarg,[JSON,Opts]) end. @@ -275,4 +275,4 @@ multi_test_result() -> --endif. \ No newline at end of file +-endif.