1use thiserror::Error;
2
3#[derive(Error, Debug)]
5pub enum ProcessingError {
6 #[error("retryable error: {0}")]
8 Retryable(#[source] anyhow::Error),
9 #[error("non-retryable error: {0}")]
11 NonRetryable(#[source] anyhow::Error),
12 #[error("connection error: {0}")]
14 Connection(#[source] anyhow::Error),
15}
16impl ProcessingError {
17 pub fn is_connection_error(&self) -> bool {
18 matches!(self, ProcessingError::Connection(_))
19 }
20}
21
22pub type HandlerError = ProcessingError;
23pub type PublisherError = ProcessingError;
24
25#[derive(Error, Debug)]
27pub enum ConsumerError {
28 #[error("consumer connection error: {0}")]
30 Connection(#[source] anyhow::Error),
31
32 #[error("consumer gap: requested offset {requested} but earliest available is {base}")]
34 Gap { requested: u64, base: u64 },
35
36 #[error("consumer reached end of stream")]
38 EndOfStream,
39}
40
41impl From<anyhow::Error> for ConsumerError {
42 fn from(err: anyhow::Error) -> Self {
43 ConsumerError::Connection(err)
45 }
46}
47
48impl From<anyhow::Error> for ProcessingError {
49 fn from(err: anyhow::Error) -> Self {
50 ProcessingError::Retryable(err)
53 }
54}