Skip to main content

isoloom_plan/
error.rs

1//! The plan's one error: what a value given to the plan names that it can't use. The plan's own
2//! findings about a spec are [`Problem`](isoloom_spec::syntax::Problem)s and refusals, not errors.
3
4use isoloom_spec::model::Target;
5use isoloom_spec::syntax::placeholder::Reference;
6
7use crate::configure::Configure;
8
9/// Why the plan can't use a value it was given.
10#[derive(Debug, thiserror::Error)]
11#[non_exhaustive]
12pub enum Error {
13    /// A CM tool `--configure` doesn't know.
14    #[error("`{0}` isn't a CM tool: use `shell`, `cloud-init` or `ansible`")]
15    UnknownTool(String),
16    /// A target that can't hand its machines to the CM tool asked for.
17    #[error("{target}: `--configure {tool}`: {why}", target = target.id())]
18    Unpaired {
19        /// The tool asked for.
20        tool: Configure,
21        /// The target.
22        target: Target,
23        /// Why they don't pair.
24        why: &'static str,
25    },
26    /// A template's placeholder that can't be read where it is.
27    #[error("a template's placeholder: {0}")]
28    Placeholder(#[source] isoloom_spec::Error),
29    /// A template's placeholder that names nothing the lab has.
30    #[error("`{{{{ {0} }}}}` names nothing this lab has")]
31    Unfilled(Reference),
32}
33
34/// A result with the plan's [`Error`].
35pub type Result<T> = std::result::Result<T, Error>;