mask a function_clause' error in encoder with a
badarg' error for api unity
This commit is contained in:
parent
95b1821a42
commit
522f72b2ce
2 changed files with 19 additions and 1 deletions
|
@ -67,7 +67,8 @@ encode_(Else, _EntryPoint) -> [Else].
|
|||
|
||||
unzip([{K, V}|Rest], EntryPoint) when is_integer(K); is_binary(K); is_atom(K) ->
|
||||
[K] ++ EntryPoint:encode(V, EntryPoint) ++ unzip(Rest, EntryPoint);
|
||||
unzip([], _) -> [end_object].
|
||||
unzip([], _) -> [end_object];
|
||||
unzip(_, _) -> erlang:error(badarg).
|
||||
|
||||
|
||||
unhitch([V|Rest], EntryPoint) ->
|
||||
|
@ -111,4 +112,16 @@ custom_error_handler_test_() ->
|
|||
)}
|
||||
].
|
||||
|
||||
improper_lists_test_() ->
|
||||
[
|
||||
{"improper proplist", ?_assertError(
|
||||
badarg,
|
||||
encode([{<<"key">>, <<"value">>}, false])
|
||||
)},
|
||||
{"improper list", ?_assertError(
|
||||
badarg,
|
||||
encode([{literal, true}, false, null])
|
||||
)}
|
||||
].
|
||||
|
||||
-endif.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue