use thiserror::Error;
pub type Result<T> = std::result::Result<T, PvError>;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum PvError {
#[error("i/o error: {0}")]
Io(#[from] std::io::Error),
#[error("invalid signature: expected magic {expected:02X?}, found {found:02X?}")]
SignatureMismatch {
expected: [u8; 4],
found: [u8; 4],
},
#[error("data corruption: {0}")]
Corruption(String),
#[error("page fault: page {page_id} is not resident")]
PageFault {
page_id: u64,
},
#[error("buffer too small: needed {needed} bytes, got {actual}")]
BufferTooSmall {
needed: usize,
actual: usize,
},
#[error("offset {offset} out of bounds for region of {size} bytes")]
OutOfBounds {
offset: usize,
size: usize,
},
#[error("invalid page type discriminant: 0x{0:02X}")]
InvalidPageType(u8),
#[error("page full: requested {needed} bytes, only {available} available")]
PageFull {
needed: usize,
available: usize,
},
#[error("content-addressable storage miss for hash {0}")]
CasMiss(String),
#[error("wasm runtime error: {0}")]
Wasm(String),
#[error("database is read-only (production mode); mutations are not permitted")]
ReadOnly,
#[error("table not found: {0}")]
TableNotFound(String),
#[error("schema error: {0}")]
Schema(String),
#[error("query parse error: {0}")]
Query(String),
#[error("query resource limit exceeded: {0}")]
ResourceLimit(String),
#[error("database is busy: {0}")]
Busy(String),
#[error("database operation was cancelled")]
Cancelled,
#[error("shared database is closed")]
DatabaseClosed,
#[error("shared transaction is closed")]
TransactionClosed,
#[error("transaction outcome is unknown: {0}")]
TransactionOutcomeUnknown(String),
#[error("transaction error: {0}")]
Transaction(String),
#[error("manifest error: {0}")]
Manifest(#[from] serde_json::Error),
#[error(transparent)]
Compliance(#[from] ComplianceError),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Error)]
#[non_exhaustive]
pub enum ComplianceError {
#[error("usage threshold exceeded without an authorizing key")]
ThresholdExceeded,
}