1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum Error {
5 #[error("CLI not found")]
6 CliNotFound,
7
8 #[error("CLI connection error: {0}")]
9 CliConnection(String),
10
11 #[error("Process failed with exit code {exit_code}")]
12 ProcessFailed { exit_code: i32 },
13
14 #[error("Not connected")]
15 NotConnected,
16
17 #[error("Not ready")]
18 NotReady,
19
20 #[error("Not in streaming mode")]
21 NotStreamingMode,
22
23 #[error("Query already started")]
24 AlreadyStarted,
25
26 #[error("Stdio error")]
27 StdioError,
28
29 #[error("JSON parse error: {0}")]
30 ParseError(String),
31
32 #[error("JSON buffer overflow")]
33 BufferOverflow,
34
35 #[error("IO error: {0}")]
36 Io(#[from] std::io::Error),
37
38 #[error("JSON error: {0}")]
39 Json(#[from] serde_json::Error),
40
41 #[error("Timeout error")]
42 Timeout(#[from] tokio::time::error::Elapsed),
43
44 #[error("Control request failed: {0}")]
45 ControlRequestFailed(String),
46
47 #[error("Oneshot receive error")]
48 OneshotRecv(#[from] tokio::sync::oneshot::error::RecvError),
49
50 #[error("Channel closed")]
51 ChannelClosed,
52
53 #[error("Invalid input: {0}")]
54 InvalidInput(String),
55
56 #[error("Task '{name}' not found in source '{source_name}'")]
58 TaskNotFound {
59 name: String,
60 version: Option<String>,
61 source_name: String,
62 },
63
64 #[error("Task '{name}' not found in any configured sources. Searched: {searched_sources:?}")]
65 TaskNotFoundInAnySources {
66 name: String,
67 version: Option<String>,
68 searched_sources: Vec<String>,
69 },
70
71 #[error("Source '{0}' not found")]
72 SourceNotFound(String),
73
74 #[error("Git operation failed: {0}")]
75 GitError(#[from] git2::Error),
76
77 #[error("Invalid package kind: expected 'TaskPackage', found '{0}'")]
78 InvalidPackageKind(String),
79
80 #[error("Task reference mismatch: expected '{expected}', found '{found}'")]
81 TaskReferenceMismatch { expected: String, found: String },
82
83 #[error("Task version mismatch for '{task}': expected '{expected}', found '{found}'")]
84 TaskVersionMismatch {
85 task: String,
86 expected: String,
87 found: String,
88 },
89
90 #[error("Task file not found: {path} (package: {package})")]
91 TaskFileNotFound { path: String, package: String },
92
93 #[error("Source configuration error: {0}")]
94 SourceConfigError(String),
95
96 #[error("Invalid version '{version}' in {context}")]
97 InvalidVersion { version: String, context: String },
98
99 #[error("YAML parsing error: {0}")]
100 YamlError(#[from] serde_yaml::Error),
101
102 #[error("Task load error: {0}")]
103 LoadError(#[from] crate::dsl::predefined_tasks::loader::LoadError),
104
105 #[error("Version error: {0}")]
106 VersionError(#[from] crate::dsl::predefined_tasks::version::VersionError),
107
108 #[error("Update error: {0}")]
109 UpdateError(#[from] crate::dsl::predefined_tasks::update::UpdateError),
110}
111
112pub type Result<T> = std::result::Result<T, Error>;