Recover from errors in custom extractors
This commit is contained in:
parent
26b832b622
commit
33d1cac5e1
|
@ -89,7 +89,19 @@ defmodule Frenzy.Pipeline.ScrapeStage do
|
|||
|
||||
module_name ->
|
||||
html_tree = Floki.parse(body)
|
||||
apply(String.to_existing_atom("Elixir." <> module_name), :extract, [html_tree])
|
||||
|
||||
try do
|
||||
apply(String.to_existing_atom("Elixir." <> module_name), :extract, [html_tree])
|
||||
rescue
|
||||
e ->
|
||||
Logger.error(
|
||||
"Encountered error extracting article content from '#{url}' with #{module_name}, falling back to default"
|
||||
)
|
||||
|
||||
Logger.error(Exception.format(:error, e, __STACKTRACE__))
|
||||
|
||||
{:ok, Readability.article(body)}
|
||||
end
|
||||
end
|
||||
|> case do
|
||||
{:ok, html} ->
|
||||
|
|
Loading…
Reference in New Issue