use thiserror::Error;
pub type DataResult<T> = std::result::Result<T, DataError>;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum DataError {
#[error("document data is corrupt: {0}")]
Corrupt(String),
#[error("document handle is poisoned by an earlier decode failure")]
Poisoned,
#[error("document is {actual} bytes compacted, over the {limit} byte cap")]
DocTooLarge {
actual: usize,
limit: usize,
},
#[error("value is {actual} bytes, over the {limit} byte limit")]
ValueTooLarge {
actual: usize,
limit: usize,
},
#[error("invalid name {name:?}: {reason}")]
InvalidName {
name: String,
reason: &'static str,
},
#[error("invalid attachment: {reason}")]
InvalidAttachment {
reason: &'static str,
},
#[error("position {position} is out of range for length {length}")]
OutOfRange {
position: usize,
length: usize,
},
#[error("data operation failed: {0}")]
Engine(String),
}