use kape::KapeError;
#[derive(Debug, thiserror::Error)]
pub enum PostgresBackendError {
#[error("PostgreSQL codec failed: {0}")]
Codec(#[source] Box<dyn std::error::Error + Send + Sync>),
#[error("PostgreSQL operation failed: {0}")]
Sqlx(#[from] sqlx::Error),
#[error("application system clock is before the Unix epoch")]
SystemClockBeforeUnixEpoch(#[source] std::time::SystemTimeError),
#[error("application Unix millisecond timestamp exceeds i64 range")]
TimestampOverflow,
#[error("TTL exceeds PostgreSQL millisecond range")]
TtlOverflow,
#[error("invalid table name '{0}'")]
InvalidTableName(String),
}
impl PostgresBackendError {
pub fn codec<E>(error: E) -> Self
where
E: std::error::Error + Send + Sync + 'static,
{
Self::Codec(Box::new(error))
}
}
impl From<PostgresBackendError> for KapeError {
fn from(error: PostgresBackendError) -> Self {
Self::backend(error)
}
}