diff --git a/lib/hub/github_api.rb b/lib/hub/github_api.rb index 8c4e1cc61d61a6c67c2d858f6727e22e875ae4a9..b9c18b5298061a169fecabb5edd87d0ba981cd09 100644 --- a/lib/hub/github_api.rb +++ b/lib/hub/github_api.rb @@ -173,11 +173,14 @@ module Hub apply_authentication(req, url) yield req if block_given? - res = http.start { http.request(req) } - res.extend ResponseMethods - res - rescue SocketError => err - raise Context::FatalError, "error with #{type.to_s.upcase} #{url} (#{err.message})" + + begin + res = http.start { http.request(req) } + res.extend ResponseMethods + return res + rescue SocketError => err + raise Context::FatalError, "error with #{type.to_s.upcase} #{url} (#{err.message})" + end end def request_uri url