language_barrier_core/
error.rs1use thiserror::Error;
2
3#[derive(Error, Debug)]
5pub enum ToolError {
6 #[error("Tool not found: {0}")]
8 NotFound(String),
9
10 #[error("Failed to generate schema for tool '{0}': {1}")]
12 SchemaGenerationError(String, serde_json::Error),
13
14 #[error("Failed to parse arguments for tool '{0}': {1}")]
16 ArgumentParsingError(String, serde_json::Error),
17
18 #[error("Invalid arguments for tool: {0}")]
20 InvalidArguments(String),
21
22 #[error("Tool execution failed: {0}")]
24 ExecutionError(String),
25
26 #[error("Type mismatch after execution for tool '{0}': Expected different output type")]
28 OutputTypeMismatch(String),
29}
30
31#[derive(Error, Debug)]
33pub enum Error {
34 #[error("Serialization error: {0}")]
36 Serialization(#[from] serde_json::Error),
37
38 #[error("HTTP request error: {0}")]
40 Request(#[from] reqwest::Error),
41
42 #[error("Couldn't parse base url")]
43 BaseUrlError(#[from] url::ParseError),
44
45 #[error("Rate limit exceeded: {0}")]
47 RateLimit(String),
48
49 #[error("Authentication error: {0}")]
51 Authentication(String),
52
53 #[error("Model not supported: {0}")]
55 UnsupportedModel(String),
56
57 #[error("Provider not available: {0}")]
59 ProviderUnavailable(String),
60
61 #[error("Context length exceeded: {0}")]
63 ContextLengthExceeded(String),
64
65 #[error("Tool not found: {0}")]
67 ToolNotFound(String),
68
69 #[error("Invalid tool parameter: {0}")]
71 InvalidToolParameter(String),
72
73 #[error("Invalid tool arguments: {0}")]
75 InvalidToolArguments(String),
76
77 #[error("Tool execution error: {0}")]
79 ToolExecutionError(String),
80
81 #[error("Tool error: {0}")]
83 Tool(#[from] ToolError),
84
85 #[error("Provider feature not supported: {0}")]
87 ProviderFeatureNotSupported(String),
88
89 #[error("{0}")]
91 Other(String),
92}
93
94pub type Result<T> = std::result::Result<T, Error>;