Fix marshaling error details exposing (#13)

The second argument of `erlang:error/2` must be a list.
This commit is contained in:
Andrey Fadeev 2019-07-17 12:49:03 +03:00 committed by GitHub
parent 9a86adf1b1
commit b54b396f63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -367,7 +367,7 @@ marshal({maybe, T}, V) ->
marshal(T, V);
marshal({enum, Choices = [_ | _]} = T, V) when is_atom(V) ->
_ = lists:member(V, Choices) orelse error(badarg, {T, V}),
_ = lists:member(V, Choices) orelse erlang:error(badarg, [T, V]),
V;
marshal(atom, V) when is_atom(V) ->
@ -380,7 +380,7 @@ marshal(integer, V) when is_integer(V) ->
V;
marshal(T, V) ->
error(badarg, {T, V}).
erlang:error(badarg, [T, V]).
apply_action({set_timer, V}, CA) ->
CA#mg_stateproc_ComplexAction{
@ -488,9 +488,9 @@ unmarshal(timestamp, V) when is_binary(V) ->
{ok, {Date, Time, USec, TZOffset}} when TZOffset == undefined orelse TZOffset == 0 ->
{{Date, Time}, USec};
{ok, _} ->
error(badarg, {timestamp, V, badoffset});
erlang:error(badarg, [timestamp, V, badoffset]);
{error, Reason} ->
error(badarg, {timestamp, V, Reason})
erlang:error(badarg, [timestamp, V, Reason])
end;
unmarshal({list, T}, V) when is_list(V) ->
@ -507,7 +507,7 @@ unmarshal({enum, Choices = [_ | _]} = T, V) when is_atom(V) ->
true ->
V;
false ->
error(badarg, {T, V})
erlang:error(badarg, [T, V])
end;
unmarshal(atom, V) when is_binary(V) ->
@ -520,4 +520,4 @@ unmarshal(integer, V) when is_integer(V) ->
V;
unmarshal(T, V) ->
error(badarg, {T, V}).
erlang:error(badarg, [T, V]).

View File

@ -67,7 +67,7 @@ marshal(V) when is_tuple(V) ->
marshal(V) when is_map(V) ->
wrap([marshal(map), wrap(genlib_map:truemap(fun (Ke, Ve) -> {marshal(Ke), marshal(Ve)} end, V))]);
marshal(V) ->
error({badarg, V}).
erlang:error(badarg, [V]).
-spec unmarshal(machinery_msgpack:t()) ->
eterm().