use std::error::Error as StdError;
use std::time::Duration;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum PubSubError {
#[error("pubsub client error: {0}")]
Connect(#[source] Box<dyn StdError + Send + Sync>),
#[error("pubsub admin error for '{name}': {source}")]
Admin {
name: String,
#[source]
source: Box<dyn StdError + Send + Sync>,
},
#[error("pubsub receive error on '{subscription}': {source}")]
Receive {
subscription: String,
#[source]
source: Box<dyn StdError + Send + Sync>,
},
#[error("pubsub publish error to '{topic}': {source}")]
Publish {
topic: String,
#[source]
source: Box<dyn StdError + Send + Sync>,
},
#[error("pubsub broker is not connected")]
NotConnected,
#[error("invalid pubsub subscription descriptor: {0}")]
InvalidDescriptor(String),
#[error(
"a delayed retry of {requested:?} outlives the subscription's maximum lease of {lease:?}; \
the delivery would come back before the delay elapsed. Raise it with \
GooglePubSub::max_lease, or ask for a shorter delay"
)]
DelayBeyondLease {
requested: Duration,
lease: Duration,
},
}
pub(crate) fn box_err<E>(err: E) -> Box<dyn StdError + Send + Sync>
where
E: StdError + Send + Sync + 'static,
{
Box::new(err)
}