Skip to content
Browse files

Catch errors when we can't reach Yahoo

  • Loading branch information...
1 parent dee5473 commit 84d9ce6b53bba1cfa06eb527c252f2bb71affd40 @jamiew committed Sep 2, 2012
Showing with 7 additions and 3 deletions.
  1. +7 −3 fatbot.rb
View
10 fatbot.rb
@@ -219,9 +219,13 @@ def ops?(nick)
on :channel, /^\$(.*)$/i do
ticker = match[0].to_s.upcase
url = "http://download.finance.yahoo.com/d/quotes.csv?s=#{ticker}&f=sb2b3jk"
- raw = open(url).read.chomp
- data = raw.split(',')
- msg channel, "Current $#{ticker} price: #{data[1]} -- http://www.google.com/finance?q=#{ticker}"
+ begin
+ raw = open(url).read.chomp
+ data = raw.split(',')
+ msg channel, "Current $#{ticker} price: #{data[1]} -- http://www.google.com/finance?q=#{ticker}"
+ rescue
+ msg channel, "Error trying to fetch data for #{ticket}: #{$!.inspect}"
+ end
end

0 comments on commit 84d9ce6

Please sign in to comment.
Something went wrong with that request. Please try again.