cheat_bail

Macro cheat_bail 

Source
macro_rules! cheat_bail {
    (
        protects = $protects:expr,
        severity = $severity:expr,
        cheats = [$($cheat:expr),+ $(,)?],
        consequence = $consequence:expr,
        $($arg:tt)*
    ) => { ... };
}
Expand description

Bail with cheat-aware error message.

Like anyhow::bail!() but includes cheat documentation in the error.

§Arguments

  • protects - What user scenario this check protects
  • severity - “CRITICAL”, “HIGH”, “MEDIUM”, or “LOW”
  • cheats - Array of ways this check could be cheated
  • consequence - What users experience if cheated
  • Format string and args for the actual error message

§Example

if !partition_exists {
    cheat_bail!(
        protects = "Disk partitioning works",
        severity = "CRITICAL",
        cheats = ["Return Ok without checking", "Increase timeout"],
        consequence = "No partitions, installation fails",
        "Partition {} not found", "vda1"
    );
}