signstar_yubihsm2/automation/
error.rs1use std::fmt::Display;
4
5use crate::automation::command::CommandName;
6
7#[derive(Debug)]
9pub struct FileBackedScenarioReturnValueMismatch {
10 pub(crate) file_backed_scenario_command: CommandName,
11 pub(crate) command_return_value: CommandName,
12}
13
14impl Display for FileBackedScenarioReturnValueMismatch {
15 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16 write!(
17 f,
18 "{} -> {}",
19 self.file_backed_scenario_command, self.command_return_value
20 )
21 }
22}
23
24#[derive(Debug, thiserror::Error)]
26pub enum Error {
27 #[error(
29 "Mismatches between commands in file backed scenarios and the collected return values exist:\n{}",
30 mismatches
31 .iter()
32 .map(ToString::to_string)
33 .collect::<Vec<_>>()
34 .join("\n")
35 )]
36 MismatchingReturnValueForFileBackedScenario {
37 mismatches: Vec<FileBackedScenarioReturnValueMismatch>,
39 },
40
41 #[error(
43 "The scenario tracks {scenario} authenticated command chains and the scenario return value {scenario_return_value}"
44 )]
45 MismatchingNumberOfAuthenticatedCommandChains {
46 scenario: usize,
48
49 scenario_return_value: usize,
51 },
52
53 #[error(
56 "The authenticated command chain tracks {authenticated_command_chain} commands while the list of command return values is {command_return_values}"
57 )]
58 MismatchingNumberOfCommands {
59 authenticated_command_chain: usize,
61
62 command_return_values: usize,
64 },
65}