   end
 
   # Fetch data from the URL in parameter.
-  # Return an empty string on error.
   defp fetch_data(url) do
     try do
       case HTTPotion.get(url, [follow_redirects: true, headers: ["User-Agent": "Exagg"]]) do
-        %HTTPotion.Response{body: body} -> body
-        _ ->
-          Logger.error "Error fetching " <> url
-          ""
+        %HTTPotion.Response{body: body} -> {:ok, body}
+        %HTTPotion.ErrorResponse{message: message} -> {:error, message}
       end
     rescue
-      _ ->
-        Logger.error "Error fetching " <> url
-        ""
+      ex -> {:error, ex}
     end
   end
 
   # Parse XML feed data.
-  # Returns an empty list of entries on error.
   defp parse_feed(xml) do
     try do
        case FeederEx.parse(xml) do
-          {:ok, feed, _} -> feed
-          {:error, _} -> %{entries: [], title: ""}
+          {:ok, feed, _} -> {:ok, feed}
+          {:error, code} -> {:error, code}
        end
     rescue
-      _ -> %{entries: [], title: ""}
+      ex -> {:error, ex}
     catch
-      _ -> %{entries: [], title: ""}
+      ex -> {:error, ex}
     end
   end
 


  # Update items for the feed in parameter.
  def sync_feed(feed) do
    parsed_feed = feed.url |> fetch_data |> parse_feed

    items = Enum.map(parsed_feed.entries, fn(entry) ->
      %{
        feed_id: feed.id,


  alias Exagg.Feed
  alias Exagg.Item
  alias Exagg.Repo

  import Ecto.Query
