use super::ClientConfigBuilderError;
use crate::{
formats::{ErrorCode, FormatError},
models::{NodeId, PartitionId, TopicName},
};
use thiserror::Error;
pub type Result<T> = std::result::Result<T, ClientError>;
#[derive(Debug, Error)]
pub enum ClientError {
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Protocol error: {0}")]
Format(#[from] FormatError),
#[error("ClientConfig builder error: {0}")]
ConfigBuilderError(#[from] ClientConfigBuilderError),
#[error("TopicCreation error: {errors:?}")]
TopicCreation { errors: Vec<(TopicName, ErrorCode)> },
#[error("TopicDeletion error: {errors:?}")]
TopicDeletion { errors: Vec<(TopicName, ErrorCode)> },
#[error(
"Leader not found for the topic partition (name={topic_name}, partition_id={partition_id})"
)]
TopicPartitionLeaderNotFound {
topic_name: TopicName,
partition_id: PartitionId,
},
#[error("Metadata for node (id={node_id}) not found")]
NodeMetadataNotFound { node_id: NodeId },
}