1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum Error {
5 #[error("Step not found: {0}")]
6 StepNotFound(String),
7
8 #[error("Args error: {0}")]
9 Args(String),
10
11 #[error("Expression error: {0}")]
12 Expression(String),
13
14 #[error("Assertion failed: {0}")]
15 Assertion(String),
16
17 #[error("IO error: {0}")]
18 Io(#[from] std::io::Error),
19
20 #[error("YAML parse error: {0}")]
21 Yaml(#[from] serde_yaml::Error),
22
23 #[error("JSON error: {0}")]
24 Json(#[from] serde_json::Error),
25
26 #[error("Step error: {0}")]
27 Step(#[from] StepError),
28
29 #[error("Container error: {0}")]
30 Container(String),
31
32 #[error("Environment variable not found: {0}")]
33 EnvVar(String),
34
35 #[error("{0}")]
36 Custom(String),
37}
38
39#[derive(Error, Debug)]
40pub enum StepError {
41 #[error("Assertion failed: {0}")]
42 Assertion(String),
43
44 #[error("{0}")]
45 Custom(String),
46}
47
48impl StepError {
49 pub fn assertion(msg: impl Into<String>) -> Self {
50 StepError::Assertion(msg.into())
51 }
52
53 pub fn custom(msg: impl Into<String>) -> Self {
54 StepError::Custom(msg.into())
55 }
56}
57
58pub type Result<T> = std::result::Result<T, Error>;