Sha256: 58f51e4219b64db0cbbba615b09bcb6fe813b3cf5f94765cfc79b52dbbb28787

Contents?: true

Size: 599 Bytes

Versions: 12

Compression:

Stored size: 599 Bytes

Contents

module Rdkafka
  class RdkafkaError < RuntimeError
    attr_reader :rdkafka_response

    def initialize(response)
      raise TypeError.new("Response has to be an integer") unless response.is_a? Integer
      @rdkafka_response = response
    end

    def code
      code = Rdkafka::FFI.rd_kafka_err2name(@rdkafka_response).downcase
      if code[0] == "_"
        code[1..-1].to_sym
      else
        code.to_sym
      end
    end

    def to_s
      "#{Rdkafka::FFI.rd_kafka_err2str(@rdkafka_response)} (#{code})"
    end

    def is_partition_eof?
      code == :partition_eof
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rdkafka-0.1.11 lib/rdkafka/error.rb
rdkafka-0.1.10 lib/rdkafka/error.rb
rdkafka-0.1.9 lib/rdkafka/error.rb
rdkafka-0.1.8 lib/rdkafka/error.rb
rdkafka-0.1.7 lib/rdkafka/error.rb
rdkafka-0.1.6 lib/rdkafka/error.rb
rdkafka-0.1.5 lib/rdkafka/error.rb
rdkafka-0.1.4 lib/rdkafka/error.rb
rdkafka-0.1.3 lib/rdkafka/error.rb
rdkafka-0.1.2 lib/rdkafka/error.rb
rdkafka-0.1.1 lib/rdkafka/error.rb
rdkafka-0.1.0 lib/rdkafka/error.rb