summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2015-05-12 19:32:24 -0500
committerTristan Sloughter <t@crashfast.com>2015-05-12 19:55:06 -0500
commit1643f4a1fc8a480c20ce972d9df47669111fff22 (patch)
tree1d6cab85bdb2af503e23f646bbfbf8a6aa209038
parent1fe93136c426a0c742134f392cc7f4d4d7ef7b3b (diff)
wrap fetch errors in rebar_fetch PRV_ERROR
-rw-r--r--src/rebar_fetch.erl8
-rw-r--r--src/rebar_pkg_resource.erl11
2 files changed, 10 insertions, 9 deletions
diff --git a/src/rebar_fetch.erl b/src/rebar_fetch.erl
index 96bbff1..0bb2270 100644
--- a/src/rebar_fetch.erl
+++ b/src/rebar_fetch.erl
@@ -30,7 +30,7 @@ download_source(AppDir, Source, State) ->
true ->
true;
Error ->
- throw(Error)
+ throw(?PRV_ERROR(Error))
catch
C:T ->
?DEBUG("rebar_fetch exception ~p ~p ~p", [C, T, erlang:get_stacktrace()]),
@@ -65,10 +65,12 @@ needs_update(AppDir, Source, State) ->
true
end.
+format_error({failed_extract, CachePath}) ->
+ io_lib:format("Failed to extract package: ~s", [CachePath]);
format_error({bad_etag, Source}) ->
- io_lib:format("MD5 Checksum comparison failed for: ~p", [Source]);
+ io_lib:format("MD5 Checksum comparison failed for: ~s", [Source]);
format_error({fetch_fail, Source}) ->
- io_lib:format("Failed to fetch and copy dep: ~p", [Source]);
+ io_lib:format("Failed to fetch and copy dep: ~s", [Source]);
format_error({bad_checksum, File}) ->
io_lib:format("Checksum mismatch against tarball in ~s", [File]);
format_error({bad_registry_checksum, File}) ->
diff --git a/src/rebar_pkg_resource.erl b/src/rebar_pkg_resource.erl
index 56e08fc..8bbd963 100644
--- a/src/rebar_pkg_resource.erl
+++ b/src/rebar_pkg_resource.erl
@@ -9,7 +9,6 @@
,needs_update/2
,make_vsn/1]).
--include_lib("providers/include/providers.hrl").
-include("rebar.hrl").
-define(DEFAULT_CDN, "https://s3.amazonaws.com/s3.hex.pm/tarballs").
@@ -44,7 +43,7 @@ cached_download(TmpDir, CachePath, Pkg, Url, ETag, State) ->
?DEBUG("Download ~s error, using ~s from cache", [Url, CachePath]),
serve_from_cache(TmpDir, CachePath, Pkg, State);
error ->
- throw(request_failed)
+ request_failed
end.
serve_from_cache(TmpDir, CachePath, Pkg, State) ->
@@ -54,11 +53,11 @@ serve_from_cache(TmpDir, CachePath, Pkg, State) ->
ok = erl_tar:extract({binary, Contents}, [{cwd, TmpDir}, compressed]),
{ok, true};
{_Bin, Chk, Chk} ->
- ?PRV_ERROR({failed_extract, CachePath});
+ {failed_extract, CachePath};
{Chk, _Reg, Chk} ->
- ?PRV_ERROR({bad_registry_checksum, CachePath});
+ {bad_registry_checksum, CachePath};
{_Bin, _Reg, _Tar} ->
- ?PRV_ERROR({bad_checksum, CachePath})
+ {bad_checksum, CachePath}
end.
serve_from_download(TmpDir, CachePath, Package, ETag, Binary, State) ->
@@ -69,7 +68,7 @@ serve_from_download(TmpDir, CachePath, Package, ETag, Binary, State) ->
serve_from_cache(TmpDir, CachePath, Package, State);
FileETag ->
?DEBUG("Download ETag ~s doesn't match cached ETag ~s", [ETag, FileETag]),
- ?PRV_ERROR({bad_download, CachePath})
+ {bad_download, CachePath}
end.