Skip to content

Commit

Permalink
Handle http errors from fetching remote files
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszwojcikowski committed Dec 9, 2024
1 parent 71ce749 commit 47a787d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/waffle/file.ex
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,21 @@ defmodule Waffle.File do
{:ok, :retry} -> request(remote_path, headers, options, tries + 1)
{:error, :out_of_tries} -> {:error, :recv_timeout}
end

{:ok, 503, _headers, client_ref} = response ->
case retry(tries, options) do
{:ok, :retry} ->
request(remote_path, headers, options, tries + 1)

{:error, :out_of_tries} ->
:hackney.close(client_ref)
{:error, {:waffle_hackney_error, response}}
end

{:ok, _, _, client_ref} = response ->
:hackney.close(client_ref)
{:error, {:waffle_hackney_error, response}}


_err ->
{:error, :waffle_hackney_error}
Expand Down

0 comments on commit 47a787d

Please sign in to comment.