summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuke Bakken <lbakken@pivotal.io>2018-09-05 06:27:44 -0700
committerLuke Bakken <lbakken@pivotal.io>2018-09-05 06:27:44 -0700
commite0eaae0a25145aea260e225616a254bd1b2ed6ab (patch)
tree32c50ed1181e1fece7f069600720055588c85725 /src
parentb21eacf62975bc18250dece13bb5f24c2bd147d8 (diff)
downloadrabbitmq-server-git-e0eaae0a25145aea260e225616a254bd1b2ed6ab.tar.gz
Fix a potential badmatch error
You can get `badmatch` if you run the broker with arguments like this: ``` make RABBITMQ_ALLOW_INPUT=true RABBITMQ_ADVANCED_CONFIG_FILE=/Users/lbakken/issues/pt/159000315-conf-format-check/test3/rabbitmq.conf RABBITMQ_CONFIG_FILE=/Users/lbakken/issues/pt/159000315-conf-format-check/test3/advanced.config run-broke ``` With this change, the following message is printed: ``` ERROR: RABBITMQ_ADVANCED_CONFIG_FILE: Expected extension .config, got extension .conf for file /Users/lbakken/issues/pt/159000315-conf-format-check/test3/rabbitmq.conf ```
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_config.erl17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/rabbit_config.erl b/src/rabbit_config.erl
index 79f4a754bf..43248df60e 100644
--- a/src/rabbit_config.erl
+++ b/src/rabbit_config.erl
@@ -253,7 +253,9 @@ validate_config_files() ->
assert_config("", _) -> ok;
assert_config(none, _) -> ok;
assert_config(Filename, Env) ->
- ".config" = filename:extension(Filename),
+ assert_config(filename:extension(Filename), Filename, Env).
+
+assert_config(".config", Filename, Env) ->
case filelib:is_regular(Filename) of
true ->
case file:consult(Filename) of
@@ -282,11 +284,15 @@ assert_config(Filename, Env) ->
end;
false ->
ok
- end.
+ end;
+assert_config(BadExt, Filename, Env) ->
+ {error, {"ERROR: '~s': Expected extension '.config', got extension '~s' for file '~s'~n", [Env, BadExt, Filename]}}.
assert_conf("", _) -> ok;
assert_conf(Filename, Env) ->
- ".conf" = filename:extension(Filename),
+ assert_conf(filename:extension(Filename), Filename, Env).
+
+assert_conf(".conf", Filename, Env) ->
case filelib:is_regular(Filename) of
true ->
case file:consult(Filename) of
@@ -302,5 +308,6 @@ assert_conf(Filename, Env) ->
end;
false ->
ok
- end.
-
+ end;
+assert_conf(BadExt, Filename, Env) ->
+ {error, {"ERROR: '~s': Expected extension '.config', got extension '~s' for file '~s'~n", [Env, BadExt, Filename]}}.