use thiserror::Error;
#[derive(Debug, Error)]
pub enum StoreError {
#[error("backend error: {0}")]
Backend(String),
#[error("chain broken on stream {stream:?} writer {writer:?} at seq {seq}: {detail}")]
ChainBroken {
stream: String,
writer: String,
seq: u64,
detail: String,
},
#[error("non-monotonic generation on {key:?}: current {current}, attempted {attempted}")]
NonMonotonicGeneration {
key: String,
current: u64,
attempted: u64,
},
#[error("malformed row: {0}")]
MalformedRow(String),
}
pub type Result<T> = std::result::Result<T, StoreError>;
impl From<rusqlite::Error> for StoreError {
fn from(e: rusqlite::Error) -> Self {
StoreError::Backend(e.to_string())
}
}