use std::error::Error as StdError;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum AmqpError {
#[error("amqp connection error: {0}")]
Connect(#[source] Box<dyn StdError + Send + Sync>),
#[error("amqp session error: {0}")]
Session(#[source] Box<dyn StdError + Send + Sync>),
#[error("amqp link attach error for '{address}': {source}")]
Attach {
address: String,
#[source]
source: Box<dyn StdError + Send + Sync>,
},
#[error("amqp publish error to '{address}': {source}")]
Publish {
address: String,
#[source]
source: Box<dyn StdError + Send + Sync>,
},
#[error("amqp publish to '{address}' not accepted: {outcome}")]
PublishNotAccepted {
address: String,
outcome: String,
},
#[error("amqp receive error on '{address}': {source}")]
Receive {
address: String,
#[source]
source: Box<dyn StdError + Send + Sync>,
},
#[error("amqp delivery on '{address}' has an unsupported body section")]
UnsupportedBody {
address: String,
},
#[error("amqp request timed out")]
RequestTimeout,
#[error("amqp broker is not connected")]
NotConnected,
#[error("invalid amqp address: {0}")]
InvalidAddress(String),
#[cfg(feature = "transaction")]
#[error("amqp transaction error: {0}")]
Transaction(String),
}
pub(crate) fn box_err<E>(err: E) -> Box<dyn StdError + Send + Sync>
where
E: StdError + Send + Sync + 'static,
{
Box::new(err)
}