25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

Recognize not_exists error in http_api

This commit is contained in:
Paweł Chmielowski 2018-10-19 10:30:05 +02:00
parent 0352b97f50
commit 5181983d97

View File

@ -301,9 +301,9 @@ handle(Call, Auth, Args, Version) when is_atom(Call), is_list(Args) ->
throw:{not_allowed, Msg} -> throw:{not_allowed, Msg} ->
{401, iolist_to_binary(Msg)}; {401, iolist_to_binary(Msg)};
throw:{error, account_unprivileged} -> throw:{error, account_unprivileged} ->
{403, 31, <<"Command need to be run with admin privilege.">>}; {403, 31, <<"Command need to be run with admin privilege.">>};
throw:{error, access_rules_unauthorized} -> throw:{error, access_rules_unauthorized} ->
{403, 32, <<"AccessRules: Account does not have the right to perform the operation.">>}; {403, 32, <<"AccessRules: Account does not have the right to perform the operation.">>};
throw:{invalid_parameter, Msg} -> throw:{invalid_parameter, Msg} ->
{400, iolist_to_binary(Msg)}; {400, iolist_to_binary(Msg)};
throw:{error, Why} when is_atom(Why) -> throw:{error, Why} when is_atom(Why) ->
@ -504,6 +504,8 @@ format_result(404, {_Name, _}) ->
format_error_result(conflict, Code, Msg) -> format_error_result(conflict, Code, Msg) ->
{409, Code, iolist_to_binary(Msg)}; {409, Code, iolist_to_binary(Msg)};
format_error_result(not_exists, Code, Msg) ->
{404, Code, iolist_to_binary(Msg)};
format_error_result(_ErrorAtom, Code, Msg) -> format_error_result(_ErrorAtom, Code, Msg) ->
{500, Code, iolist_to_binary(Msg)}. {500, Code, iolist_to_binary(Msg)}.