Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Wrap all connection exceptions in KJess::Client::Error #7

Closed
wants to merge 1 commit into from

2 participants

@eric

This makes it simpler to see if there are any connectivity-related issues or
if the problem is somewhere else.

@eric eric Wrap all connection exceptions in KJess::Client::Error
This makes it simpler to see if there are any connectivity-related issues or
if the problem is somewhere else.
456f306
@eric

Fixes #2.

@copiousfreetime

closed with 6766b35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 17, 2012
  1. @eric

    Wrap all connection exceptions in KJess::Client::Error

    eric authored
    This makes it simpler to see if there are any connectivity-related issues or
    if the problem is somewhere else.
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 0 deletions.
  1. +11 −0 lib/kjess/connection.rb
View
11 lib/kjess/connection.rb
@@ -60,6 +60,8 @@ def connect
# @sock.setsockopt(Socket::SOL_TCP, Socket::TCP_KEEPINTVL, keepalive[:intvl])
# @sock.setsockopt(Socket::SOL_TCP, Socket::TCP_KEEPCNT, keepalive[:probes])
return sock
+ rescue => e
+ raise Error, "Could not connect to #{host}:#{port}: #{e.class}: #{e.message}", e.backtrace
end
# Internal: close the socket if it is not already closed
@@ -87,6 +89,9 @@ def closed?
def write( msg )
$stderr.write "--> #{msg}" if $DEBUG
socket.write( msg )
+ rescue => e
+ close
+ raise Error, "Could not write to #{host}:#{port}: #{e.class}: #{e.message}", e.backtrace
end
# Internal: read a single line from the socket
@@ -103,6 +108,9 @@ def readline( eom = Protocol::CRLF )
rescue EOFError
close
return "EOF"
+ rescue => e
+ close
+ raise Error, "Could not read from #{host}:#{port}: #{e.class}: #{e.message}", e.backtrace
end
# Internal: Read from the socket
@@ -114,6 +122,9 @@ def read( *args )
d = socket.read( *args )
$stderr.puts "<-- #{d}" if $DEBUG
return d
+ rescue => e
+ close
+ raise Error, "Could not read from #{host}:#{port}: #{e.class}: #{e.message}", e.backtrace
end
end
end
Something went wrong with that request. Please try again.