1use kape::KapeError;
2
3#[derive(Debug, thiserror::Error)]
5pub enum PostgresBackendError {
6 #[error("PostgreSQL codec failed: {0}")]
8 Codec(#[source] Box<dyn std::error::Error + Send + Sync>),
9 #[error("PostgreSQL operation failed: {0}")]
11 Sqlx(#[from] sqlx::Error),
12 #[error("application system clock is before the Unix epoch")]
14 SystemClockBeforeUnixEpoch(#[source] std::time::SystemTimeError),
15 #[error("application Unix millisecond timestamp exceeds i64 range")]
17 TimestampOverflow,
18 #[error("TTL exceeds PostgreSQL millisecond range")]
20 TtlOverflow,
21 #[error("invalid table name '{0}'")]
23 InvalidTableName(String),
24}
25
26impl PostgresBackendError {
27 pub fn codec<E>(error: E) -> Self
29 where
30 E: std::error::Error + Send + Sync + 'static,
31 {
32 Self::Codec(Box::new(error))
33 }
34}
35
36impl From<PostgresBackendError> for KapeError {
37 fn from(error: PostgresBackendError) -> Self {
38 Self::backend(error)
39 }
40}