Skip to main content

canic_backup/restore/plan/
error.rs

1//! Module: restore::plan::error
2//!
3//! Responsibility: define typed restore planning failures.
4//! Does not own: manifest validation, artifact validation, or command execution.
5//! Boundary: shared error contract for restore plan construction.
6
7use crate::manifest::ManifestValidationError;
8
9use thiserror::Error as ThisError;
10
11///
12/// RestorePlanError
13///
14/// Typed failure returned while building restore plans.
15/// Owned by restore planning and used before restore apply or runner state exists.
16///
17
18#[derive(Debug, ThisError)]
19pub enum RestorePlanError {
20    #[error("mapping contains duplicate source canister {0}")]
21    DuplicateMappingSource(String),
22
23    #[error("mapping contains duplicate target canister {0}")]
24    DuplicateMappingTarget(String),
25
26    #[error("restore plan contains duplicate target canister {0}")]
27    DuplicatePlanTarget(String),
28
29    #[error("fixed-identity member {source_canister} cannot be mapped to {target_canister}")]
30    FixedIdentityRemap {
31        source_canister: String,
32        target_canister: String,
33    },
34
35    #[error(transparent)]
36    InvalidManifest(#[from] ManifestValidationError),
37
38    #[error("field {field} must be a valid principal: {value}")]
39    InvalidPrincipal { field: &'static str, value: String },
40
41    #[error("mapping is missing source canister {0}")]
42    MissingMappingSource(String),
43
44    #[error("restore plan contains a parent cycle or unresolved dependency")]
45    RestoreOrderCycle,
46
47    #[error("mapping references unknown source canister {0}")]
48    UnknownMappingSource(String),
49}