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("unsupported restore plan version {0}")]
21    UnsupportedVersion(u16),
22
23    #[error("field {0} must not be empty")]
24    EmptyField(&'static str),
25
26    #[error("field {field} must be a valid principal: {value}")]
27    InvalidPrincipal { field: &'static str, value: String },
28
29    #[error("field {field} must be a 64-character hex sha256 value: {value}")]
30    InvalidHash { field: &'static str, value: String },
31
32    #[error("restore plan member_count is {actual}, expected {expected}")]
33    MemberCountMismatch { expected: usize, actual: usize },
34
35    #[error("restore plan projection {0} does not match its concrete members")]
36    ProjectionMismatch(&'static str),
37
38    #[error("restore plan contains duplicate source canister {0}")]
39    DuplicatePlanSource(String),
40
41    #[error("mapping contains duplicate source canister {0}")]
42    DuplicateMappingSource(String),
43
44    #[error("mapping contains duplicate target canister {0}")]
45    DuplicateMappingTarget(String),
46
47    #[error("restore plan contains duplicate target canister {0}")]
48    DuplicatePlanTarget(String),
49
50    #[error("fixed-identity member {source_canister} cannot be mapped to {target_canister}")]
51    FixedIdentityRemap {
52        source_canister: String,
53        target_canister: String,
54    },
55
56    #[error(transparent)]
57    InvalidManifest(#[from] ManifestValidationError),
58
59    #[error("mapping is missing source canister {0}")]
60    MissingMappingSource(String),
61
62    #[error("restore plan contains a parent cycle or unresolved dependency")]
63    RestoreOrderCycle,
64
65    #[error("mapping references unknown source canister {0}")]
66    UnknownMappingSource(String),
67}