1use std::error::Error;
2
3#[derive(Debug)]
4pub enum RegentError {
5 FailureToFindGroupContent,
6 FailureToParseContent(String),
7 FailureToRunCommand(String),
8 FailureToEstablishConnection(String),
9 FailedInitialization(String),
10 FailedTcpBinding(String),
11 FailedTaskDryRun(String),
12 FailedDryRunEvaluation(String),
13 FailedToApplyExpectedState(String),
14 FailedToGetSecret(String),
15 FailureToConsiderContext(String),
16 MissingInitialization(String),
17 GroupNotFound,
18 MissingGroupsList,
19 WorkFlowNotFollowed(String),
20 WrongInitialization(String),
21 AnyOtherError(String),
22 IncoherentExpectedState(String),
23 InternalLogicError(String),
24 NotConnectedToHost,
25 ConnectionLevel(String),
26 ProblemWithHostConnection(String),
27 SecretsIssue(String),
28}
29
30impl std::fmt::Display for RegentError {
31 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32 match self {
33 RegentError::FailureToFindGroupContent => write!(f, "Failure to find group content"),
34 RegentError::FailureToParseContent(e) => write!(f, "Failure to parse content: {}", e),
35 RegentError::FailureToRunCommand(e) => write!(f, "Failure to run command: {}", e),
36 RegentError::FailureToEstablishConnection(e) => {
37 write!(f, "Failure to establish connection: {}", e)
38 }
39 RegentError::FailedInitialization(e) => write!(f, "Failed initialization: {}", e),
40 RegentError::FailedTcpBinding(e) => write!(f, "Failed TCP binding: {}", e),
41 RegentError::FailedTaskDryRun(e) => write!(f, "Failed task dry run: {}", e),
42 RegentError::FailedDryRunEvaluation(e) => write!(f, "Failed dry run evaluation: {}", e),
43 RegentError::FailedToApplyExpectedState(e) => {
44 write!(f, "Failed to apply expected state: {}", e)
45 }
46 RegentError::FailedToGetSecret(e) => write!(f, "Failed to get secret: {}", e),
47 RegentError::FailureToConsiderContext(e) => {
48 write!(f, "Failure to consider context: {}", e)
49 }
50 RegentError::MissingInitialization(e) => write!(f, "Missing initialization: {}", e),
51 RegentError::GroupNotFound => write!(f, "Group not found"),
52 RegentError::MissingGroupsList => write!(f, "Missing groups list"),
53 RegentError::WorkFlowNotFollowed(e) => write!(f, "Workflow not followed: {}", e),
54 RegentError::WrongInitialization(e) => write!(f, "Wrong initialization: {}", e),
55 RegentError::AnyOtherError(e) => write!(f, "Any other error: {}", e),
56 RegentError::IncoherentExpectedState(e) => {
57 write!(f, "Incoherent expected state: {}", e)
58 }
59 RegentError::InternalLogicError(e) => write!(f, "Internal logic error: {}", e),
60 RegentError::NotConnectedToHost => write!(f, "Not connected to host"),
61 RegentError::ConnectionLevel(e) => write!(f, "Connection level: {}", e),
62 RegentError::ProblemWithHostConnection(e) => {
63 write!(f, "Problem with host connection: {}", e)
64 }
65 RegentError::SecretsIssue(e) => write!(f, "Issue related to secrets: {}", e),
66 }
67 }
68}
69
70impl Error for RegentError {}