import Ecto.Query
import Ecto.Changeset
+ require Logger
+
schema "instances" do
field(:host, :string)
field(:unreachable_since, :naive_datetime_usec)
favicon
end
rescue
- _ -> nil
+ e ->
+ Logger.warn("Instance.get_or_update_favicon(\"#{host}\") error: #{inspect(e)}")
+ nil
end
defp scrape_favicon(%URI{} = instance_uri) do
|> Floki.attribute("link[rel=icon]", "href")
|> List.first(),
favicon <- URI.merge(instance_uri, favicon_rel) |> to_string(),
- true <- is_binary(favicon),
- true <- String.length(favicon) <= 255 do
+ true <- is_binary(favicon) do
favicon
else
_ -> nil
end
rescue
- _ -> nil
+ e ->
+ Logger.warn(
+ "Instance.scrape_favicon(\"#{to_string(instance_uri)}\") error: #{inspect(e)}"
+ )
+
+ nil
end
end
end