#[derive(Debug)]
pub enum RestoreError {
SnapshotMismatch(String),
ComponentRestoreFailed {
type_name: String,
source: crate::concrete::RestoreError,
},
SpecVersionMismatch {
got: u32,
expected: u32,
},
}
impl std::fmt::Display for RestoreError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::SnapshotMismatch(reason) => write!(f, "snapshot mismatch: {reason}"),
Self::ComponentRestoreFailed { type_name, source } => {
write!(f, "component {type_name} restore failed: {source}",)
}
Self::SpecVersionMismatch { got, expected } => write!(
f,
"snapshot spec_version mismatch: got={got}, expected={expected}",
),
}
}
}
impl std::error::Error for RestoreError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Self::ComponentRestoreFailed { source, .. } => Some(source),
_ => None,
}
}
}