-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.rs
More file actions
61 lines (58 loc) · 2.5 KB
/
error.rs
File metadata and controls
61 lines (58 loc) · 2.5 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
//! Central error types for the crate.
//!
//! These errors provide a common vocabulary for failures that can happen while
//! parsing plans, validating them, invoking tools, talking to LLMs, or running
//! the execution engine.
use thiserror::Error;
/// The top-level error type used across Ready's parsing, validation, and runtime layers.
///
/// It centralizes the main failure modes exposed by the crate so callers can handle
/// planning, tool, network, and execution problems through a single error surface.
#[derive(Error, Debug)]
pub enum ReadyError {
/// A Python-like plan could not be parsed into the internal AST representation.
#[error("Plan parsing error: {0}")]
PlanParsing(String),
/// A parsed plan failed semantic validation before execution.
#[error("Plan validation error: {0}")]
PlanValidation(String),
/// An expression could not be evaluated during execution.
#[error("Expression evaluation error: {0}")]
Evaluation(String),
/// A tool reported an execution failure along with its identifier.
#[error("Tool error: {tool_id}: {message}")]
Tool { tool_id: String, message: String },
/// A referenced tool identifier was not found in the active tool registry.
#[error("Tool not found: {0}")]
ToolNotFound(String),
/// A tool identifier was registered more than once in the active registry.
#[error("Duplicate tool registration: {0}")]
DuplicateTool(String),
/// An LLM client or model interaction failed.
#[error("LLM error: {0}")]
Llm(String),
/// The interpreter failed while executing a specific step, if known.
///
/// The optional step metadata helps surface where execution stopped without
/// requiring a separate traceback structure.
#[error("Execution error at step {step_index:?}: {message}")]
Execution {
step_index: Option<usize>,
step_type: Option<String>,
message: String,
},
/// An underlying I/O operation failed.
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
/// JSON serialization or deserialization failed.
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
/// An outbound HTTP request or response handling step failed.
#[error("HTTP error: {0}")]
Http(#[from] reqwest::Error),
}
/// A crate-wide convenience alias for results that return [`ReadyError`].
///
/// This keeps public APIs concise while ensuring failures consistently use the
/// crate's shared error type.
pub type Result<T> = std::result::Result<T, ReadyError>;