use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum DensorError {
EmptyId,
EvidenceMismatch,
}
impl fmt::Display for DensorError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
DensorError::EmptyId => write!(f, "densor has an empty densor_id"),
DensorError::EvidenceMismatch => {
write!(f, "densor evidence_hash does not match its recomputed seal")
}
}
}
}
impl std::error::Error for DensorError {}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum RuntimeError {
MissingAuthority { stage: String },
AuthorityMismatch { stage: String, authority: String },
ManifestInvalid(String),
StageFailed { stage: String, reason: String },
}
impl fmt::Display for RuntimeError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
RuntimeError::MissingAuthority { stage } => {
write!(f, "stage '{stage}' declared no authority hashes (no claim without an authority anchor)")
}
RuntimeError::AuthorityMismatch { stage, authority } => {
write!(f, "stage '{stage}' authority '{authority}' is not in the manifest's frozen authority set")
}
RuntimeError::ManifestInvalid(why) => write!(f, "densor manifest invalid: {why}"),
RuntimeError::StageFailed { stage, reason } => {
write!(f, "stage '{stage}' failed: {reason}")
}
}
}
}
impl std::error::Error for RuntimeError {}