Sha256: 037c717ddbc64853ea67078e0b03c91cb42ef3aeaf7183501beef6628e3449c3

Contents?: true

Size: 1.61 KB

Versions: 32

Compression:

Stored size: 1.61 KB

Contents

require 'openssl'

module Kontena::Websocket
  class Error < StandardError

  end

  # Unable to establish connection to server
  class ConnectError < Error

  end

  # The server sent something invalid, may not be a http/ws server
  class ProtocolError < Error

  end

  # Unable to establish SSL connection to server
  class SSLConnectError < ConnectError

  end

  # Unable to establish SSL connection to server when using ssl_verify: true
  class SSLVerifyError < SSLConnectError
    attr_reader :cert, :cert_chain

    # @param verify_result [Integer] @see OpenSSL::SSL::SSLSocket#verify_result
    # @param cert [OpenSSL::X509::Certificate]
    # @param cert_chain [Array<OpenSSL::X509::Certificate>]
    # @param message [String]
    def initialize(verify_result, cert = nil, cert_chain = nil, message = nil)
      super(message)
      @verify_result = verify_result
      @cert = cert
      @cert_chain = cert_chain
    end

    def subject
      @cert.subject
    end

    def issuer
      @cert.issuer
    end

    def to_s
      "certificate verify failed: #{super}"
    end
  end

  class SocketError < Error

  end

  # connect/read/write timed out
  class TimeoutError < Error

  end

  # server closed connection
  class CloseError < Error
    attr_reader :code, :reason

    def initialize(code, reason = nil)
      super(reason)
      @code = code
      @reason = reason
    end

    def to_s
      "connection closed with code #{@code}: #{super}"
    end
  end

  # Server closed connection without sending close frame
  class EOFError < CloseError
    def initialize(message = nil)
      super(1006, message)
    end
  end
end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
kinetic_sdk-5.0.19 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/error.rb
kinetic_sdk-5.0.18 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/error.rb
kinetic_sdk-5.0.17 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/error.rb
kinetic_sdk-5.0.16 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/error.rb
kinetic_sdk-5.0.15 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/error.rb
kinetic_sdk-5.0.14 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/error.rb
kinetic_sdk-5.0.13 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/error.rb
kinetic_sdk-5.0.12 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/error.rb
kinetic_sdk-5.0.11 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/error.rb
kinetic_sdk-5.0.10 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/error.rb
kinetic_sdk-5.0.9 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/error.rb
kinetic_sdk-5.0.8 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/error.rb
kinetic_sdk-5.0.7 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/error.rb
kinetic_sdk-5.0.6 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/error.rb
kinetic_sdk-5.0.5 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/error.rb
kinetic_sdk-5.0.4 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/error.rb
kinetic_sdk-5.0.3 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/error.rb
kinetic_sdk-5.0.2 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/error.rb
kinetic_sdk-5.0.2.beta.4 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/error.rb
kinetic_sdk-5.0.2.beta.3 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/error.rb