use std::error::Error as StdError;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum PulsarError {
#[error("pulsar connection error: {0}")]
Connect(#[source] Box<dyn StdError + Send + Sync>),
#[error("pulsar subscribe error on '{topic}': {source}")]
Subscribe {
topic: String,
#[source]
source: Box<dyn StdError + Send + Sync>,
},
#[error("pulsar receive error on '{topic}': {source}")]
Receive {
topic: String,
#[source]
source: Box<dyn StdError + Send + Sync>,
},
#[error("pulsar publish error to '{topic}': {source}")]
Publish {
topic: String,
#[source]
source: Box<dyn StdError + Send + Sync>,
},
#[error("pulsar broker is not connected")]
NotConnected,
#[error("invalid pulsar descriptor: {0}")]
Invalid(String),
}
pub(crate) fn box_err<E>(err: E) -> Box<dyn StdError + Send + Sync>
where
E: StdError + Send + Sync + 'static,
{
Box::new(err)
}