Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/processone/ejabberd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Chmielowski <pchmielowski@process-one.net>2019-04-03 13:04:36 +0300
committerPaweł Chmielowski <pchmielowski@process-one.net>2019-04-03 13:05:39 +0300
commit623a9ec3ba35ff0d04465889d033b16743d9d68b (patch)
tree5e89a579f837192f138ae759ebc2c09e4c502ff9 /src/mod_http_api.erl
parent65a6532cd989315786d68bc9c6989606a038c70b (diff)
Return proper error message for duplicate or missing args in http_api call
Diffstat (limited to 'src/mod_http_api.erl')
-rw-r--r--src/mod_http_api.erl16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/mod_http_api.erl b/src/mod_http_api.erl
index 39a98a967..e3a738a07 100644
--- a/src/mod_http_api.erl
+++ b/src/mod_http_api.erl
@@ -330,19 +330,23 @@ handle2(Call, Auth, Args, Version) when is_atom(Call), is_list(Args) ->
format_command_result(Call, Auth, Res, Version)
end.
-get_elem_delete(A, L, F) ->
+get_elem_delete(Call, A, L, F) ->
case proplists:get_all_values(A, L) of
[Value] -> {Value, proplists:delete(A, L)};
[_, _ | _] ->
- %% Crash reporting the error
- exit({duplicated_attribute, A, L});
+ ?INFO_MSG("Command ~s call rejected, it has duplicate attribute ~w",
+ [Call, A]),
+ throw({invalid_parameter,
+ io_lib:format("Request have duplicate argument: ~w", [A])});
[] ->
case F of
{list, _} ->
{[], L};
_ ->
- %% Report the error and then force a crash
- exit({attribute_not_found, A, L})
+ ?INFO_MSG("Command ~s call rejected, missing attribute ~w",
+ [Call, A]),
+ throw({invalid_parameter,
+ io_lib:format("Request have missing argument: ~w", [A])})
end
end.
@@ -351,7 +355,7 @@ format_args(Call, Args, ArgsFormat) ->
ArgFormat},
{Args1, Res}) ->
{ArgValue, Args2} =
- get_elem_delete(ArgName,
+ get_elem_delete(Call, ArgName,
Args1, ArgFormat),
Formatted = format_arg(ArgValue,
ArgFormat),