forked from jieyefriic/rp-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.rs
More file actions
240 lines (170 loc) · 5.67 KB
/
Copy patherror.rs
File metadata and controls
240 lines (170 loc) · 5.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
//! Unified error types for RicePrompt-Engine
use thiserror::Error;
/// Main error type for the engine
#[derive(Error, Debug)]
pub enum EngineError {
// Workflow errors
#[error("Invalid workflow: {0}")]
InvalidWorkflow(String),
#[error("No start node found in workflow")]
NoStartNode,
#[error("Multiple start nodes found")]
MultipleStartNodes,
#[error("Node not found: {0}")]
NodeNotFound(String),
#[error("Circular dependency detected")]
CircularDependency,
// Execution errors
#[error("Max iterations exceeded for edge {from} -> {to}")]
MaxIterationsExceeded { from: String, to: String },
#[error("No matching route from node: {0}")]
NoMatchingRoute(String),
#[error("Node execution failed: {0}")]
NodeExecutionFailed(String),
// Template errors
#[error("Template not found: {0}")]
TemplateNotFound(String),
#[error("Missing template reference")]
MissingTemplate,
// Provider errors
#[error("Provider not found: {0}")]
ProviderNotFound(String),
#[error("Provider error: {0}")]
ProviderError(#[from] ProviderError),
// State errors
#[error("Path not found: {0}")]
PathNotFound(String),
#[error("Short ID not found: {0}")]
ShortIdNotFound(String),
#[error("No executions for node: {0}")]
NoExecutions(String),
// Expression errors
#[error("Expression error: {0}")]
ExpressionError(#[from] ExprError),
// Supervisor errors
#[error("Supervisor tool not found: {0}")]
SupervisorToolNotFound(String),
#[error("Supervisor subgraph not found: {0}")]
SupervisorSubgraphNotFound(String),
#[error("Sub-workflow not found: {0}")]
WorkflowNotFound(String),
#[error("Supervisor planner failed to generate valid todos")]
SupervisorPlannerFailed,
#[error("Supervisor max iterations exceeded")]
SupervisorMaxIterations,
#[error("Supervisor timeout")]
SupervisorTimeout,
#[error("Supervisor tool failures exceeded: {count} failures")]
SupervisorToolFailures { count: u32 },
// Iterator errors
#[error("Iterator input is not an array: {0}")]
IteratorInvalidInput(String),
#[error("Iterator subgraph not found: {0}")]
IteratorSubgraphNotFound(String),
#[error("Iterator exceeded max iterations limit: {0}")]
IteratorMaxIterations(u32),
#[error("Iterator failed at index {index}: {message}")]
IteratorItemFailed { index: usize, message: String },
// Data connector errors
#[error("Data source not found: {0}")]
DataSourceNotFound(String),
#[error("Missing source configuration")]
MissingSource,
#[error("Unsupported source type: {0}")]
UnsupportedSource(String),
#[error("Missing connection configuration")]
MissingConnection,
#[error("Missing URL in connection")]
MissingUrl,
#[error("Invalid HTTP method: {0}")]
InvalidMethod(String),
#[error("HTTP request failed: {0}")]
HttpError(#[from] reqwest::Error),
#[error("Missing required field: {0}")]
MissingField(String),
#[error("Invalid operation: {0}")]
InvalidOperation(String),
#[error("S3 error: {0}")]
S3Error(String),
#[error("Database error: {0}")]
DatabaseError(String),
#[error("Qdrant error: {0}")]
QdrantError(String),
#[error("Redis error: {0}")]
RedisError(String),
// Transform node errors
#[error("Transform error: {0}")]
TransformError(String),
// Search node errors
#[error("Search error: {0}")]
SearchError(String),
// MCP errors
#[error("MCP error: {0}")]
McpError(String),
// State saving errors
#[error("State error: {0}")]
StateError(String),
// Serialization errors
#[error("YAML parse error: {0}")]
YamlError(#[from] serde_yaml::Error),
#[error("JSON parse error: {0}")]
JsonError(#[from] serde_json::Error),
}
/// Provider-specific errors
#[derive(Error, Debug)]
pub enum ProviderError {
#[error("API error: {status} - {message}")]
ApiError { status: u16, message: String },
#[error("Rate limited")]
RateLimited,
#[error("Authentication failed")]
AuthenticationFailed,
#[error("Invalid response: {0}")]
InvalidResponse(String),
#[error("Request failed: {0}")]
RequestFailed(String),
#[error("Timeout")]
Timeout,
}
/// Expression parsing/evaluation errors
#[derive(Error, Debug)]
pub enum ExprError {
#[error("Invalid path: {0}")]
InvalidPath(String),
#[error("JSON error: {0}")]
JsonError(#[from] serde_json::Error),
#[error("Unexpected token: {0}")]
UnexpectedToken(String),
#[error("Unexpected end of expression")]
UnexpectedEnd,
#[error("Unknown function: {0}")]
UnknownFunction(String),
#[error("Type mismatch: expected {expected}, got {got}")]
TypeMismatch { expected: String, got: String },
#[error("Node not found: {0}")]
NodeNotFound(String),
#[error("Short ID not found: {0}")]
ShortIdNotFound(String),
#[error("No executions for node")]
NoExecutions,
#[error("Index out of bounds: {0}")]
IndexOutOfBounds(i32),
#[error("Parse error: {0}")]
ParseError(String),
}
/// Validation errors for workflow YAML
#[derive(Error, Debug)]
pub enum ValidationError {
#[error("Missing required field: {0}")]
MissingField(String),
#[error("Invalid node type: {0}")]
InvalidNodeType(String),
#[error("Invalid edge: {from} -> {to}")]
InvalidEdge { from: String, to: String },
#[error("Duplicate node ID: {0}")]
DuplicateNodeId(String),
#[error("Invalid template reference: {0}")]
InvalidTemplateRef(String),
#[error("YAML parse error: {0}")]
YamlError(#[from] serde_yaml::Error),
}