summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2019-02-20 21:11:52 -0500
committerGitHub <noreply@github.com>2019-02-20 21:11:52 -0500
commit9e2e54afd74104ecb05c55e033803f41932eb940 (patch)
tree385da3aa69fbad8288b9d9209c2fd41207f9c0f8 /src
parent80c84170244ce426f2a112ddcacde21284dca59d (diff)
parent6379510ebf1c14c934960d13d29563c0494c2d90 (diff)
Merge pull request #2022 from starbelly/abort-on-auth-config-syntax-error
Abort when file:consult/1 returns an error in rebar3_hex_repos:auth_config/1
Diffstat (limited to 'src')
-rw-r--r--src/rebar_hex_repos.erl16
1 files changed, 13 insertions, 3 deletions
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.