1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-29 18:52:22 +01:00

handle unconfigured twitter's keys

This commit is contained in:
Sylvain 2016-11-24 09:38:42 +01:00
parent fc1f19a92f
commit 8419efc7f5

View File

@ -9,7 +9,12 @@ class API::FeedsController < API::ApiController
limit = 3
end
from_account = Setting.find_by(name: 'twitter_name').try(:value) || ENV['TWITTER_NAME']
@tweet_news = Feed.twitter.user_timeline(from_account, {count: limit})
begin
@tweet_news = Feed.twitter.user_timeline(from_account, {count: limit})
rescue Twitter::Error::BadRequest => e
STDERR.puts "[WARNING] Unable to retrieve the twitter feed, please check your ENV configuration. Details: #{e.message}"
render status: :no_content
end
end
end