use crabka_remote_storage::RemoteStorageError;
#[derive(Debug, thiserror::Error)]
pub enum MetadataLogError {
#[error("publish failed: {0}")]
Publish(String),
#[error("metadata partition {partition} out of range (count {count})")]
PartitionOutOfRange {
partition: i32,
count: i32,
},
#[error("metadata log closed")]
Closed,
#[error("metadata log error: {0}")]
Other(String),
}
impl MetadataLogError {
#[must_use]
pub fn into_storage(self) -> RemoteStorageError {
RemoteStorageError::Io(std::io::Error::other(self.to_string()))
}
}
#[derive(Debug, thiserror::Error)]
pub enum CodecError {
#[error("unexpected end of input at offset {0}")]
UnexpectedEof(usize),
#[error("unknown state byte {0} for {ctx}", ctx = .1)]
UnknownState(u8, &'static str),
#[error("length prefix {0} too large")]
LengthOverflow(u64),
#[error("decoded event rejected: {0}")]
Domain(String),
#[error("protocol codec: {0}")]
Protocol(String),
}
#[derive(Debug, thiserror::Error)]
pub enum SnapshotError {
#[error("snapshot io error: {0}")]
Io(#[from] std::io::Error),
#[error("unsupported snapshot format version {0}")]
UnsupportedVersion(u16),
#[error("malformed snapshot: {0}")]
Malformed(#[from] CodecError),
#[error("snapshot has {0} trailing bytes")]
TrailingBytes(usize),
}