Skip to content

Commit 3571ad2

Browse files
authored
Merge pull request #134 from tomaszwojcikowski/http-503-errors
Handle http errors from fetching remote files
2 parents 71ce749 + 47a787d commit 3571ad2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/waffle/file.ex

+15
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,21 @@ defmodule Waffle.File do
215215
{:ok, :retry} -> request(remote_path, headers, options, tries + 1)
216216
{:error, :out_of_tries} -> {:error, :recv_timeout}
217217
end
218+
219+
{:ok, 503, _headers, client_ref} = response ->
220+
case retry(tries, options) do
221+
{:ok, :retry} ->
222+
request(remote_path, headers, options, tries + 1)
223+
224+
{:error, :out_of_tries} ->
225+
:hackney.close(client_ref)
226+
{:error, {:waffle_hackney_error, response}}
227+
end
228+
229+
{:ok, _, _, client_ref} = response ->
230+
:hackney.close(client_ref)
231+
{:error, {:waffle_hackney_error, response}}
232+
218233

219234
_err ->
220235
{:error, :waffle_hackney_error}

0 commit comments

Comments
 (0)