#[derive(Debug, thiserror::Error)]
pub enum StorageError {
#[error(transparent)]
Io(#[from] std::io::Error),
#[error("corrupt data: {0}")]
CorruptData(String),
#[error("CRC32 mismatch: expected {expected:#010x}, got {actual:#010x}")]
CorruptCrc { expected: u32, actual: u32 },
#[error("WAL replay error: {0}")]
WalReplay(String),
#[error("catalog corrupt: {0}")]
CatalogCorrupt(String),
#[error("page corrupt: {0}")]
PageCorrupt(String),
#[error("invalid identifier: {0}")]
InvalidIdentifier(String),
}
pub type Result<T> = std::result::Result<T, StorageError>;
impl From<StorageError> for std::io::Error {
fn from(e: StorageError) -> Self {
match e {
StorageError::Io(io) => io,
other => std::io::Error::other(other.to_string()),
}
}
}