use std::error::Error as StdError;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum KinesisError {
#[error("aws config error: {0}")]
Config(String),
#[error("kinesis stream error for '{stream}': {source}")]
Stream {
stream: String,
#[source]
source: Box<dyn StdError + Send + Sync>,
},
#[error("kinesis read error on '{stream}' shard '{shard}': {source}")]
Read {
stream: String,
shard: String,
#[source]
source: Box<dyn StdError + Send + Sync>,
},
#[error("kinesis record on shard '{shard}' is KPL-aggregated (unsupported)")]
AggregatedRecord {
shard: String,
},
#[error("kinesis publish error to '{stream}': {source}")]
Publish {
stream: String,
#[source]
source: Box<dyn StdError + Send + Sync>,
},
#[error("kinesis lease store error for stream '{stream}' shard '{shard}': {source}")]
Lease {
stream: String,
shard: String,
#[source]
source: Box<dyn StdError + Send + Sync>,
},
#[error("kinesis broker is not connected")]
NotConnected,
#[error("invalid kinesis descriptor: {0}")]
Invalid(String),
}
pub(crate) fn sdk_err<E, R>(
err: &aws_sdk_kinesis::error::SdkError<E, R>,
) -> Box<dyn StdError + Send + Sync>
where
E: StdError + Send + Sync + 'static,
R: std::fmt::Debug + Send + Sync + 'static,
{
Box::from(aws_sdk_kinesis::error::DisplayErrorContext(err).to_string())
}