summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2019-07-04 16:01:51 -0400
committerFred Hebert <mononcqc@ferd.ca>2019-07-04 16:06:53 -0400
commit9e4a191f46bbf86bfe75f19ddfa1048b1660faba (patch)
tree32f7e4c8d285ce66bfd64c86069073f1c5f43f7b /src
parentd80804015388ca5b4197396748b1b247c2d9d2fd (diff)
Fix crash when a dependency is missing app file
Patch up and add tests on #2112
Diffstat (limited to 'src')
-rw-r--r--src/rebar_app_discover.erl11
-rw-r--r--src/rebar_prv_app_discovery.erl2
2 files changed, 10 insertions, 3 deletions
diff --git a/src/rebar_app_discover.erl b/src/rebar_app_discover.erl
index 0b7eeb1..0c15bb2 100644
--- a/src/rebar_app_discover.erl
+++ b/src/rebar_app_discover.erl
@@ -87,7 +87,9 @@ format_error({module_list, File}) ->
format_error({missing_module, 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]).
+ 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
@@ -351,7 +353,7 @@ 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) ->
- case rebar_config:consult_app_file(AppFile) of
+ try rebar_config:consult_app_file(AppFile) of
[{application, AppName, AppDetails}] ->
AppVsn = proplists:get_value(vsn, AppDetails),
Applications = proplists:get_value(applications, AppDetails, []),
@@ -370,8 +372,11 @@ create_app_info(AppInfo, AppDir, AppFile) ->
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
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.