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:
authorEvgeny Khramtsov <ekhramtsov@process-one.net>2019-06-14 12:33:26 +0300
committerEvgeny Khramtsov <ekhramtsov@process-one.net>2019-06-14 12:33:26 +0300
commita02cff0e780bb735531594c4ece81e8628f79782 (patch)
tree6fe7d8219d14f58183be1741fcea262c216db447 /src/ejabberd_hooks.erl
parentd48c067681d4ab25f7b97559757d8e7865ac0251 (diff)
Use new configuration validator
Diffstat (limited to 'src/ejabberd_hooks.erl')
-rw-r--r--src/ejabberd_hooks.erl15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/ejabberd_hooks.erl b/src/ejabberd_hooks.erl
index bbd2050a3..6a5caaaca 100644
--- a/src/ejabberd_hooks.erl
+++ b/src/ejabberd_hooks.erl
@@ -151,11 +151,13 @@ run(Hook, Args) ->
-spec run(atom(), binary() | global, list()) -> ok.
run(Hook, Host, Args) ->
- case ets:lookup(hooks, {Hook, Host}) of
+ try ets:lookup(hooks, {Hook, Host}) of
[{_, Ls}] ->
run1(Ls, Hook, Args);
[] ->
ok
+ catch _:badarg ->
+ ok
end.
-spec run_fold(atom(), any(), list()) -> any().
@@ -171,11 +173,13 @@ run_fold(Hook, Val, Args) ->
-spec run_fold(atom(), binary() | global, any(), list()) -> any().
run_fold(Hook, Host, Val, Args) ->
- case ets:lookup(hooks, {Hook, Host}) of
+ try ets:lookup(hooks, {Hook, Host}) of
[{_, Ls}] ->
run_fold1(Ls, Hook, Val, Args);
[] ->
Val
+ catch _:badarg ->
+ Val
end.
%%%----------------------------------------------------------------------
@@ -190,7 +194,7 @@ run_fold(Hook, Host, Val, Args) ->
%% {stop, Reason}
%%----------------------------------------------------------------------
init([]) ->
- ets:new(hooks, [named_table, {read_concurrency, true}]),
+ _ = ets:new(hooks, [named_table, {read_concurrency, true}]),
{ok, #state{}}.
%%----------------------------------------------------------------------
@@ -381,13 +385,14 @@ safe_apply(Hook, Module, Function, Args) ->
apply(Module, Function, Args)
end
catch ?EX_RULE(E, R, St) when E /= exit; R /= normal ->
+ Stack = ?EX_STACK(St),
?ERROR_MSG("Hook ~p crashed when running ~p:~p/~p:~n" ++
string:join(
- ["** Reason = ~p"|
+ ["** ~s"|
["** Arg " ++ integer_to_list(I) ++ " = ~p"
|| I <- lists:seq(1, length(Args))]],
"~n"),
[Hook, Module, Function, length(Args),
- {E, R, ?EX_STACK(St)}|Args]),
+ misc:format_exception(2, E, R, Stack)|Args]),
'EXIT'
end.