diff options
author | Evgeny Khramtsov <ekhramtsov@process-one.net> | 2019-07-12 13:59:33 +0300 |
---|---|---|
committer | Evgeny Khramtsov <ekhramtsov@process-one.net> | 2019-07-12 13:59:33 +0300 |
commit | f0c0e4a6fc94268b9acde3367a8ddff1cd912138 (patch) | |
tree | 8b41b236fd714545e1161f143e7b4fdde22b20e9 /src | |
parent | Add call/5 and multicall/5 to ejabberd_cluster (diff) |
Don't crash when attempt to get an option for unknown virtual host
Log a warning instead and retry with a global scope
Diffstat (limited to 'src')
-rw-r--r-- | src/ejabberd_config.erl | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/ejabberd_config.erl b/src/ejabberd_config.erl index 59b8e4fc9..f6f1a192b 100644 --- a/src/ejabberd_config.erl +++ b/src/ejabberd_config.erl @@ -149,12 +149,21 @@ get_option(Opt, Default) -> -spec get_option(option()) -> term(). get_option(Opt) when is_atom(Opt) -> get_option({Opt, global}); -get_option(Opt) -> +get_option({O, Host} = Opt) -> Tab = case get_tmp_config() of undefined -> ejabberd_options; T -> T end, - ets:lookup_element(Tab, Opt, 2). + try ets:lookup_element(Tab, Opt, 2) + catch ?EX_RULE(error, badarg, St) when Host /= global -> + StackTrace = ?EX_STACK(St), + Val = get_option({O, global}), + ?WARNING_MSG("Option '~s' is not defined for virtual host '~s'. " + "This is a bug, please report it with the following " + "stacktrace included:~n** ~s", + [O, Host, misc:format_exception(2, error, badarg, StackTrace)]), + Val + end. -spec set_option(option(), term()) -> ok. set_option(Opt, Val) when is_atom(Opt) -> |