diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2019-07-07 16:37:36 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-07 16:37:36 -0400 |
commit | 11be2bd0e1015394607296b4eff21f9d4b4bbc7a (patch) | |
tree | e89bcec265b5b2a9524d727e103ad14e9eb78113 /src | |
parent | a5d777a2d75953fbadada2814f858aadd4cf0b8d (diff) | |
parent | 9e4a191f46bbf86bfe75f19ddfa1048b1660faba (diff) |
Merge pull request #2117 from ferd/saleyn-master
Fix crash when a dependency is missing app.src file
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_app_discover.erl | 50 | ||||
-rw-r--r-- | src/rebar_prv_app_discovery.erl | 2 |
2 files changed, 33 insertions, 19 deletions
diff --git a/src/rebar_app_discover.erl b/src/rebar_app_discover.erl index 0c97ad7..0c15bb2 100644 --- a/src/rebar_app_discover.erl +++ b/src/rebar_app_discover.erl @@ -85,7 +85,12 @@ define_root_app(Apps, State) -> format_error({module_list, File}) -> io_lib:format("Error reading module list from ~p~n", [File]); format_error({missing_module, Module}) -> - io_lib:format("Module defined in app file missing: ~p~n", [Module]). + io_lib:format("Module defined in app file missing: ~p~n", [Module]); +format_error({cannot_read_app_file, AppFile}) -> + io_lib:format("Cannot read app file: ~p~n", [AppFile]); +format_error({bad_term_file, _File, _Reason} = Error) -> + rebar_file_utils:format_error(Error). + %% @doc merges configuration of a project app and the top level state %% some configuration like erl_opts must be merged into a subapp's opts @@ -348,24 +353,31 @@ app_dir(AppFile) -> %% app file. -spec create_app_info(rebar_app_info:t(), file:name(), file:name()) -> rebar_app_info:t(). create_app_info(AppInfo, AppDir, AppFile) -> - [{application, AppName, AppDetails}] = rebar_config:consult_app_file(AppFile), - AppVsn = proplists:get_value(vsn, AppDetails), - Applications = proplists:get_value(applications, AppDetails, []), - IncludedApplications = proplists:get_value(included_applications, AppDetails, []), - AppInfo1 = rebar_app_info:name( - rebar_app_info:original_vsn( - rebar_app_info:dir(AppInfo, AppDir), AppVsn), AppName), - AppInfo2 = rebar_app_info:applications( - rebar_app_info:app_details(AppInfo1, AppDetails), - IncludedApplications++Applications), - Valid = case rebar_app_utils:validate_application_info(AppInfo2) =:= true - andalso rebar_app_info:has_all_artifacts(AppInfo2) =:= true of - true -> - true; - _ -> - false - end, - rebar_app_info:dir(rebar_app_info:valid(AppInfo2, Valid), AppDir). + try rebar_config:consult_app_file(AppFile) of + [{application, AppName, AppDetails}] -> + AppVsn = proplists:get_value(vsn, AppDetails), + Applications = proplists:get_value(applications, AppDetails, []), + IncludedApplications = proplists:get_value(included_applications, AppDetails, []), + AppInfo1 = rebar_app_info:name( + rebar_app_info:original_vsn( + rebar_app_info:dir(AppInfo, AppDir), AppVsn), AppName), + AppInfo2 = rebar_app_info:applications( + rebar_app_info:app_details(AppInfo1, AppDetails), + IncludedApplications++Applications), + Valid = case rebar_app_utils:validate_application_info(AppInfo2) =:= true + andalso rebar_app_info:has_all_artifacts(AppInfo2) =:= true of + true -> + true; + _ -> + false + end, + rebar_app_info:dir(rebar_app_info:valid(AppInfo2, Valid), AppDir); + _Invalid -> + throw({error, {?MODULE, {cannot_read_app_file, AppFile}}}) + catch + throw:{error, {rebar_file_utils, Err = {bad_term_file, _File, _Reason}}} -> + throw({error, {?MODULE, Err}}) % wrap this + end. %% @doc Read in and parse the .app file if it is availabe. Do the same for %% the .app.src file if it exists. diff --git a/src/rebar_prv_app_discovery.erl b/src/rebar_prv_app_discovery.erl index f5bab49..20b7f90 100644 --- a/src/rebar_prv_app_discovery.erl +++ b/src/rebar_prv_app_discovery.erl @@ -43,6 +43,8 @@ do(State) -> {error, {rebar_packages, Error}}; throw:{error, {rebar_app_utils, Error}} -> {error, {rebar_app_utils, Error}}; + throw:{error, {rebar_app_discover, Error}} -> + {error, {rebar_app_discover, Error}}; throw:{error, Error} -> ?PRV_ERROR(Error) end. |