summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/rbot/ircbot.rb16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb
index 42e3c9b6..f15cb351 100644
--- a/lib/rbot/ircbot.rb
+++ b/lib/rbot/ircbot.rb
@@ -1042,12 +1042,16 @@ class Bot
def disconnect(message=nil)
message = @lang.get("quit") if (!message || message.empty?)
if @socket.connected?
- debug "Clearing socket"
- @socket.clearq
- debug "Sending quit message"
- @socket.emergency_puts "QUIT :#{message}"
- debug "Flushing socket"
- @socket.flush
+ begin
+ debug "Clearing socket"
+ @socket.clearq
+ debug "Sending quit message"
+ @socket.emergency_puts "QUIT :#{message}"
+ debug "Flushing socket"
+ @socket.flush
+ rescue SocketError => e
+ error "error while disconnecting socket: #{e.pretty_inspect}"
+ end
debug "Shutting down socket"
@socket.shutdown
end