aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Sloughter <[email protected]>2015-11-21 15:38:49 -0600
committerTristan Sloughter <[email protected]>2015-11-21 15:39:34 -0600
commit1cde722a7ce0760c723680414cc4af653ab8b260 (patch)
tree59e283f1a01c183f90f621fd7908faef9638d647
parentb6cbebf87e32fb6bd6d9fb7b5d624b5aa1ad740a (diff)
downloadrelx-1cde722a7ce0760c723680414cc4af653ab8b260.tar.gz
relx-1cde722a7ce0760c723680414cc4af653ab8b260.tar.bz2
relx-1cde722a7ce0760c723680414cc4af653ab8b260.zip
error out with useful message if the user provided sys.config isn't parseable
-rw-r--r--src/rlx_prv_assembler.erl19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/rlx_prv_assembler.erl b/src/rlx_prv_assembler.erl
index 9a267e4..56b99bd 100644
--- a/src/rlx_prv_assembler.erl
+++ b/src/rlx_prv_assembler.erl
@@ -89,6 +89,9 @@ format_error({ec_file_error, AppDir, TargetDir, E}) ->
format_error({config_does_not_exist, Path}) ->
io_lib:format("The config file specified for this release (~s) does not exist!",
[Path]);
+format_error({sys_config_parse_error, ConfigPath, Reason}) ->
+ io_lib:format("The config file (~s) specified for this release could not be opened or parsed: ~s",
+ [ConfigPath, file:format_error(Reason)]);
format_error({specified_erts_does_not_exist, ErtsVersion}) ->
io_lib:format("Specified version of erts (~s) does not exist",
[ErtsVersion]);
@@ -379,8 +382,12 @@ write_bin_file(State, Release, OutputDir, RelDir) ->
ReleasesDir = filename:join(OutputDir, "releases"),
generate_start_erl_data_file(Release, ReleasesDir),
copy_or_generate_vmargs_file(State, Release, RelDir),
- copy_or_generate_sys_config_file(State, RelDir),
- include_erts(State, Release, OutputDir, RelDir).
+ case copy_or_generate_sys_config_file(State, RelDir) of
+ ok ->
+ include_erts(State, Release, OutputDir, RelDir);
+ E ->
+ E
+ end.
include_nodetool(BinDir) ->
NodeToolFile = nodetool_contents(),
@@ -431,7 +438,13 @@ copy_or_generate_sys_config_file(State, RelDir) ->
false ->
?RLX_ERROR({config_does_not_exist, ConfigPath});
true ->
- copy_or_symlink_config_file(State, ConfigPath, RelSysConfPath)
+ %% validate sys.config is valid Erlang terms
+ case file:consult(ConfigPath) of
+ {ok, _} ->
+ copy_or_symlink_config_file(State, ConfigPath, RelSysConfPath);
+ {error, Reason} ->
+ ?RLX_ERROR({sys_config_parse_error, ConfigPath, Reason})
+ end
end
end.