ds_event_stream_rs_sdk/consumer/error.rs
1//! Consumer error module.
2//!
3//! This module contains error types specific to message consumption operations.
4
5use std::str::Utf8Error;
6use thiserror::Error;
7
8// region: --> ConsumerError
9
10/// Errors that can occur during message consumption operations.
11///
12/// This enum covers all possible errors when creating consumers or processing messages,
13/// including Kafka connection issues, message parsing problems, and validation errors.
14#[derive(Error, Debug)]
15pub enum ConsumerError {
16 /// Kafka client or operation errors
17 #[error("Kafka error: {0}")]
18 Kafka(#[from] rdkafka::error::KafkaError),
19
20 /// JSON serialization/deserialization errors
21 #[error("JSON error: {0}")]
22 Json(#[from] serde_json::Error),
23
24 /// UTF-8 string conversion errors
25 #[error("UTF-8 error: {0}")]
26 Utf8(#[from] Utf8Error),
27
28 /// Invalid message payload
29 #[error("Invalid payload: {0}")]
30 InvalidPayload(String),
31
32 /// Message validation errors
33 #[error("Validation error: {0}")]
34 Validation(String),
35
36 /// Errors from utility operations (bootstrap servers, etc.)
37 #[error("Utils error: {0}")]
38 Utils(#[from] crate::utils::error::UtilsError),
39}
40
41// endregion: --> ConsumerError