diff options
author | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2018-02-02 13:16:14 +0300 |
---|---|---|
committer | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2018-02-02 13:16:14 +0300 |
commit | c990abf22284b485480b678841f583ed4558362b (patch) | |
tree | 54c8376331c3486427019ff3905787cdfe47738c | |
parent | Another try to fix travis (diff) |
Improve log message when module startup has failed
-rw-r--r-- | src/gen_mod.erl | 21 |
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()) |