Additional HTTP error handling in get_article_content
This commit is contained in:
parent
b686938bfa
commit
e004b65263
|
@ -199,7 +199,8 @@ defmodule Frenzy.UpdateFeeds do
|
|||
{:ok, %HTTPoison.Response{status_code: 404}} ->
|
||||
{:err, "404 not found"}
|
||||
|
||||
{:ok, %HTTPoison.Response{status_code: 301, headers: headers}} ->
|
||||
{:ok, %HTTPoison.Response{status_code: status_code, headers: headers}}
|
||||
when status_code == 301 or status_code == 302 ->
|
||||
{"Location", new_url} =
|
||||
Enum.find(headers, fn {name, _value} ->
|
||||
name == "Location"
|
||||
|
@ -208,6 +209,9 @@ defmodule Frenzy.UpdateFeeds do
|
|||
Logger.debug("Got 301 redirect from #{url} to #{new_url}")
|
||||
get_article_content(new_url)
|
||||
|
||||
{:ok, %HTTPoison.Response{status_code: 403}} ->
|
||||
{:err, "403 Forbidden"}
|
||||
|
||||
{:error, %HTTPoison.Error{reason: reason}} ->
|
||||
{:err, reason}
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue