]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
Saner treatment for connect errors
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sat, 11 Jun 2011 14:26:09 +0000 (16:26 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sat, 11 Jun 2011 14:26:09 +0000 (16:26 +0200)
Rather than raising changing the message (a message that would not be
displayed anyway), display the (composed) error message and then reraise
without further changes.

lib/rbot/ircbot.rb
lib/rbot/ircsocket.rb

index a48251c268c216cb0a5db6d34fc54e1f8385a44b..bd75bec5d5039f4822d01a8a5460eaba3f4eea52 100644 (file)
@@ -940,8 +940,11 @@ class Bot
       quit if $interrupted > 0
       @socket.connect
       @last_rec = Time.now
-    rescue => e
-      raise e.class, "failed to connect to IRC server at #{@socket.server_uri}: #{e}"
+    rescue Exception => e
+      uri = @socket.server_uri || '<unknown>'
+      error "failed to connect to IRC server at #{uri}"
+      error e
+      raise
     end
     quit if $interrupted > 0
 
index 652b1f6dfc99883ded4027d6e0f7dc4bf5156dc1..4c11094b53f2151c9dd0118aa431a63e47da3112 100644 (file)
@@ -401,6 +401,7 @@ module Irc
         error "error while shutting down: #{e.pretty_inspect}"
       end
       @sock = nil
+      @server_uri = nil
       @sendq.clear
     end