1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, Error>;
5
6#[derive(Error, Debug)]
8pub enum Error {
9 #[error("TAP Node error: {0}")]
10 TapNode(#[from] tap_node::error::Error),
11
12 #[error("TAP Storage error: {0}")]
13 TapStorage(#[from] tap_node::storage::error::StorageError),
14
15 #[error("TAP Agent error: {0}")]
16 TapAgent(#[from] tap_agent::error::Error),
17
18 #[error("TAP Message error: {0}")]
19 TapMessage(#[from] tap_msg::error::Error),
20
21 #[error("IO error: {0}")]
22 Io(#[from] std::io::Error),
23
24 #[error("JSON serialization error: {0}")]
25 Json(#[from] serde_json::Error),
26
27 #[error("Invalid tool parameter: {0}")]
28 InvalidParameter(String),
29
30 #[error("Tool execution failed: {0}")]
31 ToolExecution(String),
32
33 #[error("Resource not found: {0}")]
34 ResourceNotFound(String),
35
36 #[error("Configuration error: {0}")]
37 Configuration(String),
38}
39
40impl Error {
41 pub fn invalid_parameter(msg: impl Into<String>) -> Self {
42 Self::InvalidParameter(msg.into())
43 }
44
45 pub fn tool_execution(msg: impl Into<String>) -> Self {
46 Self::ToolExecution(msg.into())
47 }
48
49 pub fn resource_not_found(msg: impl Into<String>) -> Self {
50 Self::ResourceNotFound(msg.into())
51 }
52
53 pub fn configuration(msg: impl Into<String>) -> Self {
54 Self::Configuration(msg.into())
55 }
56}