Sha256: 2b292d8220abfad2b7c2bc8f06b902aefc84adee287d8224ad39bdf5bfc77d7f

Contents?: true

Size: 1.72 KB

Versions: 12

Compression:

Stored size: 1.72 KB

Contents

module SSE
  #
  # Exception classes used by the SSE client.
  #
  module Errors
    #
    # An exception class representing an HTTP error response. This can be passed to the error
    # handler specified in {Client#on_error}.
    #
    class HTTPStatusError < StandardError
      def initialize(status, message)
        @status = status
        @message = message
        super("HTTP error #{status}")
      end

      # The HTTP status code.
      # @return [Int]
      attr_reader :status

      # The response body, if any.
      # @return [String]
      attr_reader :message
    end

    #
    # An exception class representing an invalid HTTP content type. This can be passed to the error
    # handler specified in {Client#on_error}.
    #
    class HTTPContentTypeError < StandardError
      def initialize(type)
        @content_type =  type
        super("invalid content type \"#{type}\"")
      end

      # The HTTP content type.
      # @return [String]
      attr_reader :type
    end

    #
    # An exception class indicating that an HTTP proxy server returned an error.
    #
    class HTTPProxyError < StandardError
      def initialize(status)
        @status = status
        super("proxy server returned error #{status}")
      end

      # The HTTP status code.
      # @return [Int]
      attr_reader :status
    end

    #
    # An exception class indicating that the client dropped the connection due to a read timeout.
    # This means that the number of seconds specified by `read_timeout` in {Client#initialize}
    # elapsed without receiving any data from the server.
    #
    class ReadTimeoutError < StandardError
      def initialize(interval)
        super("no data received in #{interval} seconds")
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ld-eventsource-2.2.2 lib/ld-eventsource/errors.rb
ld-eventsource-2.2.1 lib/ld-eventsource/errors.rb
ld-eventsource-2.2.0 lib/ld-eventsource/errors.rb
ld-eventsource-2.1.1 lib/ld-eventsource/errors.rb
ld-eventsource-2.1.0 lib/ld-eventsource/errors.rb
ld-eventsource-2.0.1 lib/ld-eventsource/errors.rb
ld-eventsource-2.0.0 lib/ld-eventsource/errors.rb
ld-eventsource-2.0.0.pre.beta.1 lib/ld-eventsource/errors.rb
ld-eventsource-1.0.3 lib/ld-eventsource/errors.rb
ld-eventsource-1.0.2 lib/ld-eventsource/errors.rb
ld-eventsource-1.0.1 lib/ld-eventsource/errors.rb
ld-eventsource-1.0.0 lib/ld-eventsource/errors.rb