From 6379510ebf1c14c934960d13d29563c0494c2d90 Mon Sep 17 00:00:00 2001 From: Bryan Paxton Date: Tue, 19 Feb 2019 02:06:41 -0600 Subject: Abort when file:consult/1 returns an error - Modified rebar_hex_repos:auth_config/1 to abort on error except in the case of enoent, in which we return an empty map. - added auth_config_errors test to test/rebar_pkg_repos_SUITE --- src/rebar_hex_repos.erl | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/rebar_hex_repos.erl b/src/rebar_hex_repos.erl index def5f49..babaa32 100644 --- a/src/rebar_hex_repos.erl +++ b/src/rebar_hex_repos.erl @@ -136,11 +136,21 @@ auth_config_file(State) -> -spec auth_config(rebar_state:t()) -> map(). auth_config(State) -> - case file:consult(auth_config_file(State)) of + AuthFile = auth_config_file(State), + case file:consult(AuthFile) of {ok, [Config]} -> Config; - _ -> - #{} + {error, Reason} when is_atom(Reason) -> + case Reason of + enoent -> + #{}; + _ -> + % TODO: map to an english reason + ?ABORT("Error reading repos auth config (~ts) : ~ts", [AuthFile, atom_to_list(Reason)]) + end; + {error, {_Line, _Mod, _Term} = Err} -> + Reason = file:format_error(Err), + ?ABORT("Error found in repos auth config (~ts) at line ~ts", [AuthFile, Reason]) end. -spec update_auth_config(map(), rebar_state:t()) -> ok. -- cgit v1.1