rich media: add try/rescue to ensure we catch parsing and fetching failures
authorWilliam Pitcock <nenolod@dereferenced.org>
Sun, 27 Jan 2019 12:21:05 +0000 (12:21 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Mon, 28 Jan 2019 05:53:17 +0000 (05:53 +0000)
lib/pleroma/web/rich_media/parser.ex

index 947dc0c3c2fef989d334f431cc4c9f29c2c9275a..7787bf9540ec24d8ef8ec431ded62f931af2439c 100644 (file)
@@ -21,9 +21,14 @@ defmodule Pleroma.Web.RichMedia.Parser do
   end
 
   defp parse_url(url) do
-    {:ok, %Tesla.Env{body: html}} = Pleroma.HTTP.get(url)
+    try do
+      {:ok, %Tesla.Env{body: html}} = Pleroma.HTTP.get(url)
 
-    html |> maybe_parse() |> get_parsed_data()
+      html |> maybe_parse() |> get_parsed_data()
+    rescue
+      _e ->
+        {:error, "Parsing error"}
+    end
   end
 
   defp maybe_parse(html) do