aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gen_mod.erl21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/gen_mod.erl b/src/gen_mod.erl
index 4bdca70f9..5f8283df7 100644
--- a/src/gen_mod.erl
+++ b/src/gen_mod.erl
@@ -218,10 +218,23 @@ start_module(Host, Module, Opts0, NeedValidation) ->
catch Class:Reason ->
ets:delete(ejabberd_modules, {Module, Host}),
ErrorText =
- io_lib:format("Problem starting the module ~s for host "
- "~s ~n options: ~p~n ~p: ~p~n~p",
- [Module, Host, Opts, Class, Reason,
- erlang:get_stacktrace()]),
+ case Reason == undef andalso
+ code:ensure_loaded(Module) /= {module, Module} of
+ true ->
+ io_lib:format("Failed to load unknown module "
+ "~s for host ~s: make sure "
+ "there is no typo and ~s.beam "
+ "exists inside either ~s or ~s "
+ "directory",
+ [Module, Host, Module,
+ filename:dirname(code:which(?MODULE)),
+ ext_mod:modules_dir()]);
+ false ->
+ io_lib:format("Problem starting the module ~s for host "
+ "~s ~n options: ~p~n ~p: ~p~n~p",
+ [Module, Host, Opts, Class, Reason,
+ erlang:get_stacktrace()])
+ end,
?CRITICAL_MSG(ErrorText, []),
maybe_halt_ejabberd(ErrorText),
erlang:raise(Class, Reason, erlang:get_stacktrace())