mirror of
https://github.com/wezm/wezm.net.git
synced 2024-12-19 02:39:54 +00:00
Handle Bit.ly exceptions
Mainly for when there is no internet connection
This commit is contained in:
parent
194890e733
commit
9114181bfe
1 changed files with 12 additions and 8 deletions
|
@ -24,6 +24,7 @@ module WezM
|
||||||
end
|
end
|
||||||
|
|
||||||
def short_url(url)
|
def short_url(url)
|
||||||
|
begin
|
||||||
@bitly ||= Bitly.new('wezm', 'R_f2bfdace56c886671086eb0c8acb9ce7')
|
@bitly ||= Bitly.new('wezm', 'R_f2bfdace56c886671086eb0c8acb9ce7')
|
||||||
@cache ||= {}
|
@cache ||= {}
|
||||||
unless u = @cache[url]
|
unless u = @cache[url]
|
||||||
|
@ -32,6 +33,9 @@ module WezM
|
||||||
puts "Cache hit on #{url}"
|
puts "Cache hit on #{url}"
|
||||||
end
|
end
|
||||||
u.short_url
|
u.short_url
|
||||||
|
rescue BitlyError
|
||||||
|
nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue