Fix exception handling inside Socket#read
authorKevin Clark <kclark@apache.org>
Wed, 18 Jun 2008 01:11:52 +0000 (01:11 +0000)
committerKevin Clark <kclark@apache.org>
Wed, 18 Jun 2008 01:11:52 +0000 (01:11 +0000)
Also remove the useless shebang

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@668973 13f79535-47bb-0310-9956-ffa450edef68

lib/rb/lib/thrift/transport/socket.rb

index 317d62b..88fed90 100644 (file)
@@ -1,5 +1,3 @@
-#!/usr/bin/env ruby
-#
 # Copyright (c) 2006- Facebook
 # Distributed under the Thrift Software License
 #
@@ -46,13 +44,13 @@ module Thrift
     def read(sz)
       begin
         data = @handle.recv(sz)
-        if (data.length == 0)
-          raise TransportException.new("Socket: Could not read #{sz} bytes from #{@host}:#{@port}")
-        end
-        return data
       rescue StandardError
         raise TransportException.new(TransportException::NOT_OPEN)
       end
+      if (data.length == 0)
+        raise TransportException.new(TransportException::UNKNOWN, "Socket: Could not read #{sz} bytes from #{@host}:#{@port}")
+      end
+      return data
     end
 
     def close