lib/manticore/response.rb
# Implementation of Callable#call
# Used by Manticore::Client to invoke the request tied to this response.
Implementation of Callable#call
Used by Manticore::Client to invoke the request tied to this response.
Implementation of Callable#call Used by Manticore :: Client to invoke the request tied to this response .
def call
      return background! if @background
      raise "Already called" if @called
      @called = true
      begin
        @client.client.execute @request, self, @context
      rescue Java::JavaNet::SocketTimeoutException => e
        ex = Manticore::SocketTimeout
      rescue Java::OrgApacheHttpConn::ConnectTimeoutException => e
        ex = Manticore::ConnectTimeout
      rescue Java::JavaNet::SocketException => e
        ex = Manticore::SocketException
      rescue Java::OrgApacheHttpClient::ClientProtocolException, Java::JavaxNetSsl::SSLHandshakeException,
             Java::OrgApacheHttpConn::HttpHostConnectException, Java::OrgApacheHttp::NoHttpResponseException,
             Java::OrgApacheHttp::ConnectionClosedException => e
        ex = Manticore::ClientProtocolException
      rescue Java::JavaNet::UnknownHostException => e
        ex = Manticore::ResolutionFailure
      rescue Java::JavaLang::IllegalArgumentException => e
        ex = Manticore::InvalidArgumentException
      rescue Java::JavaLang::IllegalStateException => e
        if (e.message || '').index('Connection pool shut down')
          ex = Manticore::ClientStoppedException
        else
          @exception = e
        end
      rescue Java::JavaLang::Exception => e 
        ex = Manticore::UnknownException
      rescue StandardError => e
        @exception = e
      end
      if ex || @exception
        @exception ||= ex.new(e)
        @handlers[:failure].call @exception
        execute_complete
        nil
      else
        execute_complete
        self
      end
    end
def call return background! if @background raise "Already called" if @called @called = true begin @client . client . execute @request , self , @context rescue Java :: JavaNet :: SocketTimeoutException => e ex = Manticore :: SocketTimeout rescue Java :: OrgApacheHttpConn :: ConnectTimeoutException => e ex = Manticore :: ConnectTimeout rescue Java :: JavaNet :: SocketException => e ex = Manticore :: SocketException rescue Java :: OrgApacheHttpClient :: ClientProtocolException , Java :: JavaxNetSsl :: SSLHandshakeException , Java :: OrgApacheHttpConn :: HttpHostConnectException , Java :: OrgApacheHttp :: NoHttpResponseException , Java :: OrgApacheHttp :: ConnectionClosedException => e ex = Manticore :: ClientProtocolException rescue Java :: JavaNet :: UnknownHostException => e ex = Manticore :: ResolutionFailure rescue Java :: JavaLang :: IllegalArgumentException => e ex = Manticore :: InvalidArgumentException rescue Java :: JavaLang :: IllegalStateException => e if ( e . message || '' ) . index ( 'Connection pool shut down' ) ex = Manticore :: ClientStoppedException else @exception = e end rescue Java :: JavaLang :: Exception => e ex = Manticore :: UnknownException rescue StandardError => e @exception = e end if ex || @exception @exception ||= ex . new ( e ) @handlers [ :failure ] . call @exception execute_complete nil else execute_complete self end end
Implementation of Callable#call
Used by Manticore::Client to invoke the request tied to this response.
Implementation of Callable#call Used by Manticore :: Client to invoke the request tied to this response .
# Handle anything we may have missed from java # TODO: If calling async, execute_complete may fail and then silently swallow exceptions. How do we fix that?