Skip to content

Commit

Permalink
Merge pull request #134 from tomaszwojcikowski/http-503-errors
Browse files Browse the repository at this point in the history
Handle http errors from fetching remote files
  • Loading branch information
achempion authored Dec 9, 2024
2 parents 71ce749 + 47a787d commit 3571ad2
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 3571ad2

Please sign in to comment.