regent_sdk/error.rs
1//! Error types for Regent SDK
2//!
3//! This module provides comprehensive error handling for all operations
4//! within the Regent SDK. All errors implement `std::error::Error` and
5//! provide detailed context for troubleshooting.
6
7use thiserror::Error;
8
9/// The primary error type for Regent SDK operations.
10///
11/// All operations in Regent SDK return this error type, which provides
12/// detailed information about what went wrong during execution.
13///
14/// # Error Variants
15///
16/// - `FailureToFindGroupContent`: Could not locate group information
17/// - `FailureToParseContent`: Parsing errors (YAML, JSON, etc.)
18/// - `FailureToRunCommand`: Command execution failed
19/// - `FailureToEstablishConnection`: Connection to host failed
20/// - `FailedInitialization`: Initialization or setup error
21/// - `FailedTcpBinding`: TCP binding failed
22/// - `FailedTaskDryRun`: Dry run of a task failed
23/// - `FailedDryRunEvaluation`: Evaluation during dry run failed
24/// - `FailedToApplyExpectedState`: Could not apply the expected state
25/// - `FailedToGetSecret`: Secret retrieval failed
26/// - `FailureToConsiderContext`: Template context rendering failed
27/// - `MissingInitialization`: Required initialization was missing
28/// - `GroupNotFound`: Requested group does not exist
29/// - `MissingGroupsList`: Groups list was not provided
30/// - `WorkFlowNotFollowed`: Required workflow was not followed
31/// - `WrongInitialization`: Initialization was incorrect
32/// - `AnyOtherError`: Generic error wrapper
33/// - `IncoherentExpectedState`: Expected state definition was inconsistent
34/// - `InternalLogicError`: Internal library error (please report)
35/// - `NotConnectedToHost`: Operation attempted without active connection
36/// - `ProblemWithHostConnection`: Connection issue with host
37/// - `SecretsIssue`: Problem with secret management
38/// - `AttributeError`: Issue with an attribute definition or execution
39/// - `TimeOutReached`: Operation timed out
40///
41#[derive(Debug, Error, Clone)]
42pub enum RegentError {
43 #[error("Failure to find group content")]
44 FailureToFindGroupContent,
45
46 #[error("Failure to parse content: '{0}'")]
47 FailureToParseContent(String),
48
49 #[error("Failure to run command: '{0}'")]
50 FailureToRunCommand(String),
51
52 #[error("Failure to establish connection: '{0}'")]
53 FailureToEstablishConnection(String),
54
55 #[error("Failed initialization: '{0}'")]
56 FailedInitialization(String),
57
58 #[error("Failed TCP binding: '{0}'")]
59 FailedTcpBinding(String),
60
61 #[error("Failed task dry run: '{0}'")]
62 FailedTaskDryRun(String),
63
64 #[error("Failed dry run evaluation: '{0}'")]
65 FailedDryRunEvaluation(String),
66
67 #[error("Failed to apply expected state: '{0}'")]
68 FailedToApplyExpectedState(String),
69
70 #[error("Failed to get secret: '{0}'")]
71 FailedToGetSecret(String),
72
73 #[error("Failure to consider context: '{0}'")]
74 FailureToConsiderContext(String),
75 #[error("Missing initialization: '{0}'")]
76 MissingInitialization(String),
77
78 #[error("Group not found")]
79 GroupNotFound,
80
81 #[error("Missing groups list")]
82 MissingGroupsList,
83
84 #[error("Workflow not followed: '{0}'")]
85 WorkFlowNotFollowed(String),
86
87 #[error("Wrong initialization: '{0}'")]
88 WrongInitialization(String),
89
90 #[error("Any other error: '{0}'")]
91 AnyOtherError(String),
92 #[error("Incoherent expected state: '{0}'")]
93 IncoherentExpectedState(String),
94
95 #[error("Internal logic error: '{0}'")]
96 InternalLogicError(String),
97
98 #[error("Not connected to host")]
99 NotConnectedToHost,
100
101 #[error("Problem with host connection: '{0}'")]
102 ProblemWithHostConnection(String),
103
104 #[error("Secrets issue: '{0}'")]
105 SecretsIssue(String),
106
107 #[error("Attribute error: '{0}'")]
108 AttributeError(String),
109
110 #[error("TimeOut reached: '{0}'")]
111 TimeOutReached(String),
112
113 #[error("Failed to get file: '{0}'")]
114 FailedToGetFile(String),
115
116 #[error("Incompatible host: '{0}'")]
117 IncompatibleHost(String),
118}