Skip to content

Commit 4d8008c

Browse files
committed
Document RdkafkaError
1 parent 0d0665c commit 4d8008c

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

.yardopts

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
--no-private
2+
--markup=markdown

lib/rdkafka/error.rb

+10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
module Rdkafka
2+
# Error returned by the underlying rdkafka library.
23
class RdkafkaError < RuntimeError
4+
# The underlying raw error response
5+
# @return [Integer]
36
attr_reader :rdkafka_response
47

8+
# @private
59
def initialize(response)
610
raise TypeError.new("Response has to be an integer") unless response.is_a? Integer
711
@rdkafka_response = response
812
end
913

14+
# This error's code, for example `:partition_eof`, `:msg_size_too_large`.
15+
# @return [Symbol]
1016
def code
1117
code = Rdkafka::FFI.rd_kafka_err2name(@rdkafka_response).downcase
1218
if code[0] == "_"
@@ -16,10 +22,14 @@ def code
1622
end
1723
end
1824

25+
# Human readable representation of this error.
26+
# @return [String]
1927
def to_s
2028
"#{Rdkafka::FFI.rd_kafka_err2str(@rdkafka_response)} (#{code})"
2129
end
2230

31+
# Whether this error indicates the partition is EOF.
32+
# @return [Boolean]
2333
def is_partition_eof?
2434
code == :partition_eof
2535
end

lib/rdkafka/producer.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def close
2525
@polling_thread.join
2626
end
2727

28-
# Produces a message to a Kafka topic. The message is added to rdkafka's queue, call wait on the returned delivery handle to make sure it is delivered.
28+
# Produces a message to a Kafka topic. The message is added to rdkafka's queue, call `wait` on the returned delivery handle to make sure it is delivered.
2929
#
3030
# When no partition is specified the underlying Kafka library picks a partition based on the key. If no key is specified, a random partition will be used.
3131
# When a timestamp is provided this is used instead of the autogenerated timestamp.

0 commit comments

Comments
 (0)