24
1
mirror of https://github.com/processone/ejabberd.git synced 2024-06-30 23:02:00 +02:00

Fixed config parsing error messages

This commit is contained in:
Alexey Shchepin 2012-12-07 16:12:49 +02:00
parent afed9e919e
commit a9b452fba9

View File

@ -188,20 +188,18 @@ normalize_hosts([Host|Hosts], PrepHosts) ->
%%% Errors reading the config file %%% Errors reading the config file
describe_config_problem(Filename, Reason) -> describe_config_problem(Filename, Reason) ->
Text1 = lists:flatten("Problem loading ejabberd config file " ++ Filename), ExitText = ["Problem loading ejabberd config file ", Filename,
Text2 = lists:flatten(" : " ++ file:format_error(Reason)), ": ", file:format_error(Reason)],
ExitText = Text1 ++ Text2, binary_to_list(iolist_to_binary(ExitText)).
ExitText.
describe_config_problem(Filename, Reason, LineNumber) -> describe_config_problem(Filename, Reason, LineNumber) ->
Text1 = lists:flatten("Problem loading ejabberd config file " ++ Filename), ExitText =
Text2 = lists:flatten(" approximately in the line " ["Problem loading ejabberd config file ", Filename,
++ file:format_error(Reason)), " approximately in the line ", file:format_error(Reason)],
ExitText = Text1 ++ Text2,
Lines = get_config_lines(Filename, LineNumber, 10, 3), Lines = get_config_lines(Filename, LineNumber, 10, 3),
?ERROR_MSG("The following lines from your configuration file might be" ?ERROR_MSG("The following lines from your configuration file might be"
" relevant to the error: ~n~s", [Lines]), " relevant to the error: ~n~s", [Lines]),
ExitText. binary_to_list(iolist_to_binary(ExitText)).
get_config_lines(Filename, TargetNumber, PreContext, PostContext) -> get_config_lines(Filename, TargetNumber, PreContext, PostContext) ->
{ok, Fd} = file:open(Filename, [read]), {ok, Fd} = file:open(Filename, [read]),