Don't die on fetching problems.
authorRoger Braun <roger@rogerbraun.net>
Fri, 15 Sep 2017 06:18:29 +0000 (08:18 +0200)
committerRoger Braun <roger@rogerbraun.net>
Fri, 15 Sep 2017 06:18:29 +0000 (08:18 +0200)
lib/pleroma/web/ostatus/ostatus.ex

index 882226172f8da39481f4dacbc35a96f032bbc772..1fd868a90860803425093aca54607b4485b8baac 100644 (file)
@@ -300,12 +300,18 @@ defmodule Pleroma.Web.OStatus do
   end
 
   def fetch_activity_from_url(url) do
-    with {:ok, activities} when length(activities) > 0 <- fetch_activity_from_atom_url(url) do
-      {:ok, activities}
-    else
-      _e -> with {:ok, activities} <- fetch_activity_from_html_url(url) do
-              {:ok, activities}
-            end
+    try do
+      with {:ok, activities} when length(activities) > 0 <- fetch_activity_from_atom_url(url) do
+        {:ok, activities}
+      else
+        _e -> with {:ok, activities} <- fetch_activity_from_html_url(url) do
+                {:ok, activities}
+              end
+      end
+    rescue
+      e ->
+        Logger.debug("Couldn't get #{url}: #{inspect(e)}")
+        {:error, "Couldn't get #{url}: #{inspect(e)}"}
     end
   end
 end