Commit 17dbd157 authored by Tiago's avatar Tiago
Browse files

move connect error routing to separate function

which can be overridable by a plugin
parent dc48931b
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -390,6 +390,14 @@ module HTTPX
      current_session.deselect_connection(self, current_selector, @cloned)
    end

    def on_connect_error(e)
      # connect errors, exit gracefully
      error = ConnectionError.new(e.message)
      error.set_backtrace(e.backtrace)
      handle_connect_error(error) if connecting?
      force_close
    end

    def on_io_error(e)
      on_error(e)
      force_close(true)
@@ -707,11 +715,7 @@ module HTTPX
           Errno::ENOENT,
           SocketError,
           IOError => e
      # connect errors, exit gracefully
      error = ConnectionError.new(e.message)
      error.set_backtrace(e.backtrace)
      handle_connect_error(error) if connecting?
      force_close
      on_connect_error(e)
    rescue TLSError, ::HTTP2::Error::ProtocolError, ::HTTP2::Error::HandshakeError => e
      # connect errors, exit gracefully
      handle_error(e)
+2 −0
Original line number Diff line number Diff line
@@ -122,6 +122,8 @@ module HTTPX

    def on_io_error: (IOError error) -> void

    def on_connect_error: (Exception error) -> void

    private

    def initialize: (http_uri uri, Options options) -> void