diff --git a/lib/articles.rb b/lib/articles.rb index ecdd83f..eebacc3 100644 --- a/lib/articles.rb +++ b/lib/articles.rb @@ -24,16 +24,20 @@ module WezM end def short_url(url) - @bitly ||= Bitly.new('wezm', 'R_f2bfdace56c886671086eb0c8acb9ce7') - @cache ||= {} - unless u = @cache[url] - u = @bitly.shorten(url) - else - puts "Cache hit on #{url}" + begin + @bitly ||= Bitly.new('wezm', 'R_f2bfdace56c886671086eb0c8acb9ce7') + @cache ||= {} + unless u = @cache[url] + u = @bitly.shorten(url) + else + puts "Cache hit on #{url}" + end + u.short_url + rescue BitlyError + nil end - u.short_url end end end -end \ No newline at end of file +end