From 8081bdf971494b673adc5bfdcd65d9281b1d15e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Pi=C4=85tyszek?= Date: Sat, 2 Jul 2016 11:50:00 +0200 Subject: [PATCH] rescue and display exceptions during feed generation --- app/services/generate_rss.rb | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/app/services/generate_rss.rb b/app/services/generate_rss.rb index 5f5b6d1..27160bd 100644 --- a/app/services/generate_rss.rb +++ b/app/services/generate_rss.rb @@ -5,14 +5,19 @@ def initialize(page) end def call - @browser.visit(@page.url) - result = { - title: fetch_title, - description: fetch_description, - url: @page.url, - articles: fetch_articles - } - @page.errors.empty? ? result : nil + begin + @browser.visit(@page.url) + result = { + title: fetch_title, + description: fetch_description, + url: @page.url, + articles: fetch_articles + } + @page.errors.empty? ? result : nil + rescue Exception => e + @page.errors[:exception] << ": #{e.message}" + nil + end end private