Additional HTTP error handling in get_article_content

This commit is contained in:
Shadowfacts 2019-06-30 21:31:24 -04:00
parent b686938bfa
commit e004b65263
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 5 additions and 1 deletions

View File

@ -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