From b44867db072da8243ed230a3d82c2a3f8c5bfcf4 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Thu, 25 Jun 2015 10:32:47 -0500 Subject: error message for bad profile config --- src/rebar_state.erl | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/rebar_state.erl') diff --git a/src/rebar_state.erl b/src/rebar_state.erl index 8125026..d0b28de 100644 --- a/src/rebar_state.erl +++ b/src/rebar_state.erl @@ -4,6 +4,8 @@ get/2, get/3, set/3, + format_error/1, + has_all_artifacts/1, code_paths/2, code_paths/3, update_code_paths/3, @@ -166,6 +168,9 @@ default(#state_t{default=Opts}) -> default(State, Opts) -> State#state_t{default=Opts}. +format_error({profile_not_list, Profile, Other}) -> + io_lib:format("Profile config must be a list but for profile '~p' config given as:~n~p", [Profile, Other]). + -spec has_all_artifacts(rebar_app_info:t()) -> true | providers:error(). has_all_artifacts(State) -> Artifacts = rebar_state:get(State, artifacts, []), @@ -291,8 +296,13 @@ apply_profiles(State=#state_t{default = Defaults, current_profiles=CurrentProfil lists:foldl(fun(default, OptsAcc) -> OptsAcc; (Profile, OptsAcc) -> - ProfileOpts = dict:from_list(proplists:get_value(Profile, ConfigProfiles, [])), - merge_opts(Profile, ProfileOpts, OptsAcc) + case proplists:get_value(Profile, ConfigProfiles, []) of + OptsList when is_list(OptsList) -> + ProfileOpts = dict:from_list(OptsList), + merge_opts(Profile, ProfileOpts, OptsAcc); + Other -> + throw(?PRV_ERROR({profile_not_list, Profile, Other})) + end end, Defaults, AppliedProfiles), State#state_t{current_profiles = AppliedProfiles, opts=NewOpts}. -- cgit v1.1