From de42646634e65a5216efe2f353352575b97b6390 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sun, 27 Jan 2019 12:21:05 +0000 Subject: [PATCH] rich media: add try/rescue to ensure we catch parsing and fetching failures --- lib/pleroma/web/rich_media/parser.ex | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/rich_media/parser.ex b/lib/pleroma/web/rich_media/parser.ex index 947dc0c3c..7787bf954 100644 --- a/lib/pleroma/web/rich_media/parser.ex +++ b/lib/pleroma/web/rich_media/parser.ex @@ -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 -- 2.45.2