forked from AkkomaGang/akkoma
rich media: add try/rescue to ensure we catch parsing and fetching failures
This commit is contained in:
parent
5d895093fd
commit
de42646634
1 changed files with 7 additions and 2 deletions
|
@ -21,9 +21,14 @@ def parse(url) do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp parse_url(url) do
|
defp parse_url(url) do
|
||||||
|
try do
|
||||||
{:ok, %Tesla.Env{body: html}} = Pleroma.HTTP.get(url)
|
{: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
|
end
|
||||||
|
|
||||||
defp maybe_parse(html) do
|
defp maybe_parse(html) do
|
||||||
|
|
Loading…
Reference in a new issue