mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
parent
5700089187
commit
bfa3125a81
@ -91,21 +91,24 @@ format_error({bad_module, Mod}, Ctx)
|
|||||||
Mods = ejabberd_config:beams(all),
|
Mods = ejabberd_config:beams(all),
|
||||||
format("~s: unknown ~s: ~s. Did you mean ~s?",
|
format("~s: unknown ~s: ~s. Did you mean ~s?",
|
||||||
[yconf:format_ctx(Ctx),
|
[yconf:format_ctx(Ctx),
|
||||||
format_module_type(Ctx), Mod,
|
format_module_type(Ctx),
|
||||||
misc:best_match(Mod, Mods)]);
|
format_module(Mod),
|
||||||
|
format_module(misc:best_match(Mod, Mods))]);
|
||||||
format_error({bad_module, Mod}, Ctx)
|
format_error({bad_module, Mod}, Ctx)
|
||||||
when Ctx == [modules] ->
|
when Ctx == [modules] ->
|
||||||
Mods = lists:filter(
|
Mods = lists:filter(
|
||||||
fun(M) ->
|
fun(M) ->
|
||||||
case atom_to_list(M) of
|
case atom_to_list(M) of
|
||||||
"mod_" ++ _ -> true;
|
"mod_" ++ _ -> true;
|
||||||
|
"Elixir.Mod" ++ _ -> true;
|
||||||
_ -> false
|
_ -> false
|
||||||
end
|
end
|
||||||
end, ejabberd_config:beams(all)),
|
end, ejabberd_config:beams(all)),
|
||||||
format("~s: unknown ~s: ~s. Did you mean ~s?",
|
format("~s: unknown ~s: ~s. Did you mean ~s?",
|
||||||
[yconf:format_ctx(Ctx),
|
[yconf:format_ctx(Ctx),
|
||||||
format_module_type(Ctx), Mod,
|
format_module_type(Ctx),
|
||||||
misc:best_match(Mod, Mods)]);
|
format_module(Mod),
|
||||||
|
format_module(misc:best_match(Mod, Mods))]);
|
||||||
format_error({bad_export, {F, A}, Mod}, Ctx)
|
format_error({bad_export, {F, A}, Mod}, Ctx)
|
||||||
when Ctx == [listen, module];
|
when Ctx == [listen, module];
|
||||||
Ctx == [listen, request_handlers];
|
Ctx == [listen, request_handlers];
|
||||||
@ -114,17 +117,18 @@ format_error({bad_export, {F, A}, Mod}, Ctx)
|
|||||||
Slogan = yconf:format_ctx(Ctx),
|
Slogan = yconf:format_ctx(Ctx),
|
||||||
case lists:member(Mod, ejabberd_config:beams(local)) of
|
case lists:member(Mod, ejabberd_config:beams(local)) of
|
||||||
true ->
|
true ->
|
||||||
format("~s: '~s' is not a ~s", [Slogan, Mod, Type]);
|
format("~s: '~s' is not a ~s",
|
||||||
|
[Slogan, format_module(Mod), Type]);
|
||||||
false ->
|
false ->
|
||||||
case lists:member(Mod, ejabberd_config:beams(external)) of
|
case lists:member(Mod, ejabberd_config:beams(external)) of
|
||||||
true ->
|
true ->
|
||||||
format("~s: third-party ~s '~s' doesn't export "
|
format("~s: third-party ~s '~s' doesn't export "
|
||||||
"function ~s/~B. If it's really a ~s, "
|
"function ~s/~B. If it's really a ~s, "
|
||||||
"consider to upgrade it",
|
"consider to upgrade it",
|
||||||
[Slogan, Type, Mod, F, A, Type]);
|
[Slogan, Type, format_module(Mod),F, A, Type]);
|
||||||
false ->
|
false ->
|
||||||
format("~s: '~s' doesn't match any known ~s",
|
format("~s: '~s' doesn't match any known ~s",
|
||||||
[Slogan, Mod, Type])
|
[Slogan, format_module(Mod), Type])
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
format_error({unknown_option, [], _} = Why, Ctx) ->
|
format_error({unknown_option, [], _} = Why, Ctx) ->
|
||||||
@ -191,6 +195,13 @@ format_error({mqtt_codec, Reason}) ->
|
|||||||
format_error(Reason) ->
|
format_error(Reason) ->
|
||||||
yconf:format_error(Reason).
|
yconf:format_error(Reason).
|
||||||
|
|
||||||
|
-spec format_module(atom()) -> string().
|
||||||
|
format_module(Mod) ->
|
||||||
|
case atom_to_list(Mod) of
|
||||||
|
"Elixir." ++ M -> M;
|
||||||
|
M -> M
|
||||||
|
end.
|
||||||
|
|
||||||
format_module_type([listen, module]) ->
|
format_module_type([listen, module]) ->
|
||||||
"listening module";
|
"listening module";
|
||||||
format_module_type([listen, request_handlers]) ->
|
format_module_type([listen, request_handlers]) ->
|
||||||
@ -306,12 +317,6 @@ path() ->
|
|||||||
binary_sep(Sep) ->
|
binary_sep(Sep) ->
|
||||||
yconf:binary_sep(Sep).
|
yconf:binary_sep(Sep).
|
||||||
|
|
||||||
beam() ->
|
|
||||||
yconf:beam().
|
|
||||||
|
|
||||||
beam(Exports) ->
|
|
||||||
yconf:beam(Exports).
|
|
||||||
|
|
||||||
timeout(Units) ->
|
timeout(Units) ->
|
||||||
yconf:timeout(Units).
|
yconf:timeout(Units).
|
||||||
|
|
||||||
@ -354,6 +359,20 @@ options(V, O) ->
|
|||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% Custom validators
|
%%% Custom validators
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
|
beam() ->
|
||||||
|
beam([]).
|
||||||
|
|
||||||
|
beam(Exports) ->
|
||||||
|
and_then(
|
||||||
|
non_empty(binary()),
|
||||||
|
fun(<<"Elixir.", _/binary>> = Val) ->
|
||||||
|
(yconf:beam(Exports))(Val);
|
||||||
|
(<<C, _/binary>> = Val) when C >= $A, C =< $Z ->
|
||||||
|
(yconf:beam(Exports))(<<"Elixir.", Val/binary>>);
|
||||||
|
(Val) ->
|
||||||
|
(yconf:beam(Exports))(Val)
|
||||||
|
end).
|
||||||
|
|
||||||
acl() ->
|
acl() ->
|
||||||
either(
|
either(
|
||||||
atom(),
|
atom(),
|
||||||
|
Loading…
Reference in New Issue
Block a user