improve error handling when sql calling with (empty|unknown) host.

see #191
This commit is contained in:
HAMANO Tsukasa 2014-05-01 00:20:58 +09:00
parent ec6c58a21c
commit 0904b8b8ff
3 changed files with 4 additions and 2 deletions

View File

@ -300,6 +300,9 @@ get_password_with_authmodule(User, Server) ->
-spec is_user_exists(binary(), binary()) -> boolean().
is_user_exists(User, <<"">>) ->
false;
is_user_exists(User, Server) ->
%% Check if the user exists in all authentications module except the module
%% passed as parameter

View File

@ -212,7 +212,6 @@ is_user_exists(User, Server) ->
true; %% Account exists
{selected, [<<"password">>], []} ->
false; %% Account does not exist
{error, unknownhost} -> false;
{error, Error} -> {error, Error}
catch
_:B -> {error, B}

View File

@ -141,7 +141,7 @@ sql_call(Host, Msg) ->
case get(?STATE_KEY) of
undefined ->
case ejabberd_odbc_sup:get_random_pid(Host) of
none -> {error, unknownhost};
none -> {error, <<"Unknown Host">>};
Pid ->
(?GEN_FSM):sync_send_event(Pid,{sql_cmd, Msg, now()},
?TRANSACTION_TIMEOUT)