diff options
author | Tristan Sloughter <t@crashfast.com> | 2015-05-12 19:23:37 -0500 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2015-05-12 19:55:06 -0500 |
commit | 1fe93136c426a0c742134f392cc7f4d4d7ef7b3b (patch) | |
tree | 2ba20f81e062681c963f8b17041f46cb3f320a04 | |
parent | 56c925b75b86a6304da75635874722348ee21351 (diff) |
throw errors returned by resource:download/3
-rw-r--r-- | src/rebar_fetch.erl | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/src/rebar_fetch.erl b/src/rebar_fetch.erl index 235aa03..96bbff1 100644 --- a/src/rebar_fetch.erl +++ b/src/rebar_fetch.erl @@ -26,24 +26,34 @@ lock_source(AppDir, Source, State) -> -spec download_source(file:filename_all(), rebar_resource:resource(), rebar_state:t()) -> true | {error, any()}. download_source(AppDir, Source, State) -> - try - Resources = rebar_state:resources(State), - Module = get_resource_type(Source, Resources), - TmpDir = ec_file:insecure_mkdtemp(), - AppDir1 = ec_cnv:to_list(AppDir), - {ok, _} = Module:download(TmpDir, Source, State), - ec_file:mkdir_p(AppDir1), - code:del_path(filename:absname(filename:join(AppDir1, "ebin"))), - ec_file:remove(filename:absname(AppDir1), [recursive]), - ?DEBUG("Moving checkout ~p to ~p", [TmpDir, filename:absname(AppDir1)]), - ok = rebar_file_utils:mv(TmpDir, filename:absname(AppDir1)), - true + try download_source_(AppDir, Source, State) of + true -> + true; + Error -> + throw(Error) catch C:T -> ?DEBUG("rebar_fetch exception ~p ~p ~p", [C, T, erlang:get_stacktrace()]), throw(?PRV_ERROR({fetch_fail, Source})) end. +download_source_(AppDir, Source, State) -> + Resources = rebar_state:resources(State), + Module = get_resource_type(Source, Resources), + TmpDir = ec_file:insecure_mkdtemp(), + AppDir1 = ec_cnv:to_list(AppDir), + case Module:download(TmpDir, Source, State) of + {ok, _} -> + ec_file:mkdir_p(AppDir1), + code:del_path(filename:absname(filename:join(AppDir1, "ebin"))), + ec_file:remove(filename:absname(AppDir1), [recursive]), + ?DEBUG("Moving checkout ~p to ~p", [TmpDir, filename:absname(AppDir1)]), + ok = rebar_file_utils:mv(TmpDir, filename:absname(AppDir1)), + true; + Error -> + Error + end. + -spec needs_update(file:filename_all(), rebar_resource:resource(), rebar_state:t()) -> boolean() | {error, string()}. needs_update(AppDir, Source, State) -> Resources = rebar_state:resources(State), |