Skip to content

Commit

Permalink
make config file errors more understandable to the user
Browse files Browse the repository at this point in the history
Signed-off-by: Jordan Wilberding <[email protected]>
  • Loading branch information
ericbmerritt authored and jwilberding committed Oct 30, 2012
1 parent 92dcabc commit 89e5d70
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/rcl_prv_config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ do(State) ->
lists:foldl(fun load_config/2, {ok, State}, ConfigFiles).

-spec format_error(Reason::term()) -> iolist().
format_error({consult, Reason}) ->
file:format_error(Reason);
format_error({consult, ConfigFile, Reason}) ->
io_lib:format("Unable to read file ~s: ~s", [ConfigFile,
file:format_error(Reason)]);
format_error({invalid_term, Term}) ->
io_lib:format("Invalid term in config file: ~p", [Term]).

Expand All @@ -50,7 +51,7 @@ load_config(ConfigFile, {ok, State}) ->
ok = file:set_cwd(filename:dirname(ConfigFile)),
Result = case file:consult(ConfigFile) of
{error, Reason} ->
?RCL_ERROR({consult, Reason});
?RCL_ERROR({consult, ConfigFile, Reason});
{ok, Terms} ->
lists:foldl(fun load_terms/2, {ok, State}, Terms)
end,
Expand Down

0 comments on commit 89e5d70

Please sign in to comment.