Exception: Kafka::ResponseError

Inherits:
Error
  • Object
show all
Defined in:
lib/kafka/error.rb

Overview

::Kafka::ResponseError is an Error that can be raised based on an :error_code as returned from the librdkafka API.

See Also:

  • RD_KAFKA_RESP_ERR_*
  • rd_kafka_resp_err_t

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, message = nil) ⇒ ResponseError

Returns a new instance of ResponseError.



15
16
17
18
# File 'lib/kafka/error.rb', line 15

def initialize(code, message = nil)
  @code = code
  @message = message
end

Instance Attribute Details

#codeObject (readonly)



13
14
15
# File 'lib/kafka/error.rb', line 13

def code
  @code
end

Instance Method Details

#internal?true, false

Returns true when the error is from internal to librdkafka or false when the error was received from a broker or timeout.

Returns:

  • (true)

    Error was internal to librdkafka

  • (false)

    Error was returned by the cluster

See Also:



33
34
35
# File 'lib/kafka/error.rb', line 33

def internal?
  code < 0
end

#nameString

Returns the librdkafka error constant for this error.

Returns:

  • (String)


22
23
24
# File 'lib/kafka/error.rb', line 22

def name
  "RD_KAFKA_RESP_ERR_#{::Kafka::FFI.rd_kafka_err2name(@code)}"
end

#to_sString

Returns a human readable error description

Returns:

  • (String)

    Human readable description of the error.



40
41
42
# File 'lib/kafka/error.rb', line 40

def to_s
  @message || ::Kafka::FFI.rd_kafka_err2str(@code)
end