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

Re-raise exceptions caught in gen_mod:start_module/3 (EJAB-1335)

Modules configured by the administrator normally should not be treated
as optional, so a exception (error, exit, throw) to start them should not
be caught and logged only.

This patch re-raises a caught exception instead of ignoring the
exception and inserting the module's opts on success. That way
gen_mod:get_module_opt/4 should work while calling Module:start/2.
This commit is contained in:
Andreas Köhler 2010-11-02 16:18:16 +01:00 committed by Badlop
parent 2ebfd4090a
commit 01b6cd3aba

View File

@ -81,13 +81,13 @@ start_module2(Host, Module, Opts) ->
ets:insert(ejabberd_modules, ets:insert(ejabberd_modules,
#ejabberd_module{module_host = {Module, Host}, #ejabberd_module{module_host = {Module, Host},
opts = Opts}), opts = Opts}),
case catch Module:start(Host, Opts) of try Module:start(Host, Opts)
{'EXIT', Reason} -> catch Class:Reason ->
del_module_mnesia(Host, Module), del_module_mnesia(Host, Module),
ets:delete(ejabberd_modules, {Module, Host}), ets:delete(ejabberd_modules, {Module, Host}),
?ERROR_MSG("~p", [Reason]); ?ERROR_MSG("Problem starting the module ~p for host ~p with options:~n ~p~n ~p: ~p",
_ -> [Module, Host, Opts, Class, Reason]),
ok erlang:raise(Class, Reason, erlang:get_stacktrace())
end. end.
%% @doc Stop the module in a host, and forget its configuration. %% @doc Stop the module in a host, and forget its configuration.