summaryrefslogtreecommitdiff
path: root/src/rebar_app_utils.erl
diff options
context:
space:
mode:
authorTristan Sloughter <tristan.sloughter@gmail.com>2015-08-23 09:21:35 -0500
committerTristan Sloughter <tristan.sloughter@gmail.com>2015-08-23 09:21:35 -0500
commit657a1bf52e4de27d3d302de707fdd53fa3d0632e (patch)
tree5724696bc29083a23f05174e3daf669b065426de /src/rebar_app_utils.erl
parent725e2e9d255c7c2f8c680f60eb1b82284d55a333 (diff)
parentdae1b4cc827edbe805c74ae4abcff7ad5571f569 (diff)
Merge pull request #742 from tsloughter/pkg_check
improve error messages for packages by checking its existance before fetch
Diffstat (limited to 'src/rebar_app_utils.erl')
-rw-r--r--src/rebar_app_utils.erl18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl
index b14c50a..7239fe7 100644
--- a/src/rebar_app_utils.erl
+++ b/src/rebar_app_utils.erl
@@ -126,6 +126,8 @@ parse_dep(Parent, {Name, Vsn}, DepsDir, IsLock, State) when is_list(Vsn); is_bin
not_found ->
{PkgName, PkgVsn} = parse_goal(ec_cnv:to_binary(Name)
,ec_cnv:to_binary(Vsn)),
+ %% Verify package actually exists. This will throw a missing_package exception
+ rebar_packages:deps(PkgName, PkgVsn, State),
Source = {pkg, PkgName, PkgVsn},
rebar_app_info:resource_type(dep_to_app(Parent, DepsDir, PkgName, PkgVsn, Source, IsLock, State), pkg)
end;
@@ -137,6 +139,8 @@ parse_dep(Parent, Name, DepsDir, IsLock, State) when is_atom(Name); is_binary(Na
{ok, _App} ->
dep_to_app(root, DepsDir, Name, [], [], IsLock, State);
not_found ->
+ %% Verify package actually exists. This will throw a missing_package exception
+ rebar_packages:deps(PkgName, PkgVsn, State),
Source = {pkg, PkgName, PkgVsn},
rebar_app_info:resource_type(dep_to_app(Parent, DepsDir, PkgName, PkgVsn, Source, IsLock, State), pkg)
end;
@@ -153,6 +157,8 @@ parse_dep(Parent, {_Name, {pkg, Name, Vsn}, Level}, DepsDir, IsLock, State) when
{ok, _App} ->
dep_to_app(root, DepsDir, Name, [], [], IsLock, State);
not_found ->
+ %% Verify package actually exists. This will throw a missing_package exception
+ rebar_packages:deps(Name, Vsn, State),
Source = {pkg, Name, Vsn},
rebar_app_info:resource_type(dep_to_app(Parent, DepsDir, Name, Vsn, Source, IsLock, State), pkg)
end;
@@ -193,6 +199,10 @@ dep_to_app(Parent, DepsDir, Name, Vsn, Source, IsLock, State) ->
end,
rebar_app_info:resource_type(rebar_app_info:parent(AppInfo, Parent), ResourceType).
+format_error({missing_package, Package}) ->
+ io_lib:format("Package not found in registry: ~s", [Package]);
+format_error({parse_dep, Dep}) ->
+ io_lib:format("Failed parsing dep ~p", [Dep]);
format_error(Error) ->
io_lib:format("~p", [Error]).
@@ -212,8 +222,12 @@ parse_goal(Name, Constraint) ->
end.
get_package(Dep, State) ->
- {ok, HighestDepVsn} = rebar_packages:find_highest_matching(Dep, "0", ?PACKAGE_TABLE, State),
- {Dep, HighestDepVsn}.
+ case rebar_packages:find_highest_matching(Dep, "0", ?PACKAGE_TABLE, State) of
+ {ok, HighestDepVsn} ->
+ {Dep, HighestDepVsn};
+ none ->
+ throw(?PRV_ERROR({missing_package, ec_cnv:to_binary(Dep)}))
+ end.
-spec has_all_beams(file:filename_all(), [module()]) ->
true | ?PRV_ERROR({missing_module, module()}).