fix onebox exception, if oneboxes fail on save we log a warning to the log

This commit is contained in:
Sam 2013-08-20 11:38:10 +10:00
parent d43bd55e5b
commit f4d833da27

View File

@ -9,11 +9,18 @@ class PostAnalyzer
def cook(*args) def cook(*args)
cooked = PrettyText.cook(*args) cooked = PrettyText.cook(*args)
# If we have any of the oneboxes in the cache, throw them in right away, don't # cook all oneboxes, in the past we used to defer this
# wait for the post processor. # for some reason we decided to do this inline now
# TODO: discuss on http://meta.discourse.org what the correct thing is to do
# keep in mind some oneboxes may take a long time to build
result = Oneboxer.apply(cooked) do |url, elem| result = Oneboxer.apply(cooked) do |url, elem|
Oneboxer.invalidate(url) if args.last[:invalidate_oneboxes] Oneboxer.invalidate(url) if args.last[:invalidate_oneboxes]
begin
Oneboxer.onebox url Oneboxer.onebox url
rescue => e
Rails.logger.warn("Failed to cook onebox: #{e.message} #{e.backtrace}")
nil
end
end end
cooked = result.to_html if result.changed? cooked = result.to_html if result.changed?