use kuatia_types::AccountId;
#[derive(Debug)]
pub enum StoreError {
NotFound(String),
AlreadyExists(String),
VersionConflict {
account: AccountId,
expected: u64,
actual: u64,
},
Internal(String),
}
impl std::fmt::Display for StoreError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::NotFound(msg) => write!(f, "not found: {msg}"),
Self::AlreadyExists(msg) => write!(f, "already exists: {msg}"),
Self::VersionConflict {
account,
expected,
actual,
} => {
write!(
f,
"version conflict for {account:?}: expected {expected}, got {actual}"
)
}
Self::Internal(msg) => write!(f, "internal error: {msg}"),
}
}
}
impl std::error::Error for StoreError {}