pub struct KafkaError { /* private fields */ }Expand description
Base Kafka error with common fields shared by all error types.
Corresponds to Java’s KafkaException / ApiException base class.
Contains the protocol error code and an optional custom message —
exactly the state Java’s KafkaException carries. Fatality is NOT state
here: like Java, it is derived from the error’s identity, see
request_utils::RequestUtils::is_fatal_error.
Specific error types (e.g., TopicAuthorizationError) embed this
struct and add their own fields, mirroring Java’s error subclasses.
Do not confuse this with Error, the flat enum that wraps it — or with
that enum’s KafkaError variant, which holds exactly
one of these and nothing else.
§Examples
use confluent_kafka::common::Error;
let err = Error::kafka_message_source("send failed", Error::timeout("expired"));
let base = err.kafka_error().expect("a bare Kafka error embeds a KafkaError");
assert_eq!(base.message(), "send failed");
assert_eq!(base.source().map(Error::message), Some("expired"));Classification lives on Error, which wraps this type — Java’s
KafkaException has no isRetriable() either:
use confluent_kafka::common::Error;
assert!(Error::timeout("expired").is_retriable_error());
assert!(!Error::kafka().is_retriable_error());Implementations§
Trait Implementations§
Source§impl Clone for KafkaError
impl Clone for KafkaError
Source§fn clone(&self) -> KafkaError
fn clone(&self) -> KafkaError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for KafkaError
impl Debug for KafkaError
Source§impl Display for KafkaError
impl Display for KafkaError
Source§impl Error for KafkaError
impl Error for KafkaError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Wired to the stored source. This impl used to be empty, so source()
answered None even when a cause was present — Java’s
KafkaException(String, Throwable) keeps it.