Skip to content

Commit 77ac380

Browse files
hairyhummichaelklishin
authored andcommitted
Improve the error message when a config file is not in the correct format
(cherry picked from commit 61f7e9c)
1 parent a1cfb53 commit 77ac380

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/rabbit_config.erl

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,14 @@ assert_config(Filename, Env) ->
260260
{ok, _} -> ok;
261261
{error, {1, erl_parse, Err}} ->
262262
{error, {"ERROR: Unable to parse erlang terms from ~s file: ~s~n"
263-
"Error: ~p~n"
264-
"Check that the file has the correct format. "
265-
"If you are using the new ini-style format, the file "
266-
"extension should be '.conf'~n",
263+
"ERROR: Reason: ~p~n"
264+
"ERROR: Check that the file is in the erlang terms format. " ++
265+
case Env of
266+
"RABBITMQ_CONFIG_FILE" ->
267+
"If you are using the new ini-style format, the file "
268+
"extension should be '.conf'~n";
269+
_ -> ""
270+
end,
267271
[Env, Filename, Err]}};
268272
{error, Err} ->
269273
{error, {"ERROR Unable to parse erlang terms from ~s file: ~s~n"
@@ -281,9 +285,9 @@ assert_conf(Filename, Env) ->
281285
true ->
282286
case file:read_file(Filename) of
283287
{ok, <<"[", _/binary>>} ->
284-
{error, {"ERROR: wrong format of the config file ~s: ~s~n"
285-
"Check that the file is in the new ini-style config format "
286-
"If you are using the old format the file extension should"
288+
{error, {"ERROR: Wrong format of the config file ~s: ~s~n"
289+
"ERROR: Check that the file is in the new ini-style config format "
290+
"If you are using the old format the file extension should "
287291
"be .config~n",
288292
[Env, Filename]}};
289293
_ ->

0 commit comments

Comments
 (0)