use thiserror::Error;
#[derive(Error, Debug)]
pub enum MeruError {
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("corruption: {0}")]
Corruption(String),
#[error("schema mismatch: {0}")]
SchemaMismatch(String),
#[error("key not found")]
NotFound,
#[error("object store error: {0}")]
ObjectStore(String),
#[error("parquet error: {0}")]
Parquet(String),
#[error("iceberg error: {0}")]
Iceberg(String),
#[error("WAL error: {0}")]
Wal(String),
#[error("compaction error: {0}")]
Compaction(String),
#[error("invalid argument: {0}")]
InvalidArgument(String),
#[error("operation not permitted: database is read-only")]
ReadOnly,
#[error("database is closed")]
Closed,
#[error("object already exists: {0}")]
AlreadyExists(String),
#[error("change feed below retention: requested {requested}, low_water {low_water} — escalate to Iceberg snapshot scan")]
ChangeFeedBelowRetention { requested: u64, low_water: u64 },
}
pub type Result<T> = std::result::Result<T, MeruError>;