diff options
author | Raine Virta <rane@kapsi.fi> | 2009-12-15 23:57:51 +0200 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-12-21 10:30:45 +0100 |
commit | 682e7f1708b9534385467b3d707433cb256b6405 (patch) | |
tree | 8a6defc234a347b35c47224a32f9865df497571e /data/rbot | |
parent | 4fa049e0386d8044f0063e90b7e7efbca9c712de (diff) |
spotify: handle errors
Diffstat (limited to 'data/rbot')
-rw-r--r-- | data/rbot/plugins/lib_spotify.rb | 3 | ||||
-rw-r--r-- | data/rbot/plugins/spotify.rb | 6 |
2 files changed, 7 insertions, 2 deletions
diff --git a/data/rbot/plugins/lib_spotify.rb b/data/rbot/plugins/lib_spotify.rb index a30157c6..24caf428 100644 --- a/data/rbot/plugins/lib_spotify.rb +++ b/data/rbot/plugins/lib_spotify.rb @@ -71,7 +71,8 @@ module ::Spotify def self.get(service, method, query, page=1) query.tr!('-','') url = "http://ws.spotify.com/#{service}/1/#{method}?q=#{CGI.escape(query)}&page=#{page}" - xml = Irc::Utils.bot.httputil.get_response(url).body + xml = Irc::Utils.bot.httputil.get(url) + raise unless xml return REXML::Document.new(xml).root end diff --git a/data/rbot/plugins/spotify.rb b/data/rbot/plugins/spotify.rb index f645a8af..95fe5842 100644 --- a/data/rbot/plugins/spotify.rb +++ b/data/rbot/plugins/spotify.rb @@ -16,7 +16,11 @@ class SpotifyPlugin < Plugin def search(m, params) method = params[:method] || 'track' - result = Spotify.search(method, params[:query].to_s) + begin + result = Spotify.search(method, params[:query].to_s) + rescue + m.reply "problems connecting to Spotify" + end if result.nil? m.reply "no results" |