Return descriptive errors from is_app_available()

This commit is contained in:
Adam Kocoloski 2010-11-30 00:46:50 +01:00 committed by Tuncer Ayaz
parent bb6d07011f
commit 8118083122

View file

@ -158,7 +158,7 @@ update_deps_code_path([Dep | Rest]) ->
Dir = filename:join(Dep#dep.dir, "ebin"), Dir = filename:join(Dep#dep.dir, "ebin"),
ok = filelib:ensure_dir(filename:join(Dir, "dummy")), ok = filelib:ensure_dir(filename:join(Dir, "dummy")),
true = code:add_patha(Dir); true = code:add_patha(Dir);
false -> {false, _} ->
true true
end, end,
update_deps_code_path(Rest). update_deps_code_path(Rest).
@ -179,12 +179,12 @@ find_deps([{App, VsnRegex, Source} | Rest], {Avail, Missing}) ->
case is_app_available(App, VsnRegex) of case is_app_available(App, VsnRegex) of
{true, AppDir} -> {true, AppDir} ->
find_deps(Rest, {[Dep#dep { dir = AppDir } | Avail], Missing}); find_deps(Rest, {[Dep#dep { dir = AppDir } | Avail], Missing});
false -> {false, _} ->
AppDir = filename:join(get_deps_dir(), Dep#dep.app), AppDir = filename:join(get_deps_dir(), Dep#dep.app),
case is_app_available(App, VsnRegex, AppDir) of case is_app_available(App, VsnRegex, AppDir) of
{true, AppDir} -> {true, AppDir} ->
find_deps(Rest, {[Dep#dep { dir = AppDir } | Avail], Missing}); find_deps(Rest, {[Dep#dep { dir = AppDir } | Avail], Missing});
false -> {false, _} ->
find_deps(Rest, {Avail, [Dep#dep { dir = AppDir } | Missing]}) find_deps(Rest, {Avail, [Dep#dep { dir = AppDir } | Missing]})
end end
end; end;
@ -209,7 +209,7 @@ require_source_engine(Source) ->
is_app_available(App, VsnRegex) -> is_app_available(App, VsnRegex) ->
case code:lib_dir(App) of case code:lib_dir(App) of
{error, bad_name} -> {error, bad_name} ->
false; {false, bad_name};
Path -> Path ->
is_app_available(App, VsnRegex, Path) is_app_available(App, VsnRegex, Path)
end. end.
@ -228,16 +228,16 @@ is_app_available(App, VsnRegex, Path) ->
nomatch -> nomatch ->
?WARN("~s has version ~p; requested regex was ~s\n", ?WARN("~s has version ~p; requested regex was ~s\n",
[AppFile, Vsn, VsnRegex]), [AppFile, Vsn, VsnRegex]),
false {false, version_mismatch}
end; end;
OtherApp -> OtherApp ->
?WARN("~s has application id ~p; expected ~p\n", [AppFile, OtherApp, App]), ?WARN("~s has application id ~p; expected ~p\n", [AppFile, OtherApp, App]),
false {false, name_mismatch}
end; end;
false -> false ->
?WARN("Expected ~s to be an app dir (containing ebin/*.app), but no .app found.\n", ?WARN("Expected ~s to be an app dir (containing ebin/*.app), but no .app found.\n",
[Path]), [Path]),
false {false, missing_app_file}
end. end.
use_source(Dep) -> use_source(Dep) ->
@ -257,11 +257,11 @@ use_source(Dep, Count) ->
%% add the app dir to our code path %% add the app dir to our code path
true = code:add_patha(Dir), true = code:add_patha(Dir),
Dep; Dep;
false -> {false, Reason} ->
%% The app that was downloaded doesn't match up (or had %% The app that was downloaded doesn't match up (or had
%% errors or something). For the time being, abort. %% errors or something). For the time being, abort.
?ABORT("Dependency dir ~s does not satisfy version regex ~s.\n", ?ABORT("Dependency dir ~s failed application validation "
[Dep#dep.dir, Dep#dep.vsn_regex]) "with reason ~p.\n", [Dep#dep.dir, Reason])
end; end;
false -> false ->
?CONSOLE("Pulling ~p from ~p\n", [Dep#dep.app, Dep#dep.source]), ?CONSOLE("Pulling ~p from ~p\n", [Dep#dep.app, Dep#dep.source]),