use kafka_protocol::messages::RequestKind;
#[derive(Debug, thiserror::Error)]
pub enum ClientError {
#[error("error while interacting with a broker: {0:?}")]
BrokerError(BrokerRequestError),
#[error("error while encoding a batch of records: {0}")]
EncodingError(String),
#[error("the specified topic has no available partitions: {0}")]
NoPartitionsAvailable(String),
#[error("the specified topic is unknown to the cluster: {0}")]
UnknownTopic(String),
}
#[derive(Debug, thiserror::Error)]
#[error("broker connection error: {kind:?}")]
pub struct BrokerRequestError {
pub(crate) payload: RequestKind,
pub(crate) kind: BrokerErrorKind,
}
#[derive(Debug, thiserror::Error)]
pub enum BrokerErrorKind {
#[error("the client is disconnected")]
Disconnected,
#[error("the broker returned a malformed response")]
MalformedBrokerResponse,
}