Provide a suggestion when unknown module is detected

This commit is contained in:
Evgeny Khramtsov 2019-04-29 21:15:52 +03:00
parent 39bbc7cad8
commit c56209a27d
2 changed files with 7 additions and 3 deletions

View File

@ -39,7 +39,7 @@
default_queue_type/1, queue_dir/0, fsm_limit_opts/1,
use_cache/1, cache_size/1, cache_missed/1, cache_life_time/1,
codec_options/1, get_plain_terms_file/2, negotiation_timeout/0,
similar_option/2]).
similar_option/2, get_modules/0]).
-export([start/2]).

View File

@ -740,11 +740,15 @@ format_module_error(Module, Fun, Arity, Opts, Class, Reason, St) ->
IsCallbackExported = erlang:function_exported(Module, Fun, Arity),
case {Class, Reason} of
{error, undef} when not IsLoaded ->
io_lib:format("Failed to ~s unknown module ~s: "
io_lib:format("Failed to ~s unknown module ~s, "
"did you mean ~s? Hint: "
"make sure there is no typo and ~s.beam "
"exists inside either ~s or ~s "
"directory",
[Fun, Module, Module,
[Fun, Module,
ejabberd_config:similar_option(
Module, ejabberd_config:get_modules()),
Module,
filename:dirname(code:which(?MODULE)),
ext_mod:modules_dir()]);
{error, undef} when not IsCallbackExported ->