1use serde::{Deserialize, Serialize};
2use thiserror::Error;
3
4#[derive(Error, Debug, Clone, Serialize, Deserialize)]
5pub enum WorkspaceError {
6 #[error("I/O error: {0}")]
7 Io(String),
8
9 #[error("Tool execution failed: {0}")]
10 ToolExecution(String),
11
12 #[error("Transport error: {0}")]
13 Transport(String),
14
15 #[error("Status error: {0}")]
16 Status(String),
17
18 #[error("Not supported: {0}")]
19 NotSupported(String),
20
21 #[error("Invalid configuration: {0}")]
22 InvalidConfiguration(String),
23
24 #[error("Remote workspace error: {0}")]
25 Remote(String),
26}
27
28pub type Result<T> = std::result::Result<T, WorkspaceError>;
29
30#[derive(Error, Debug, Clone, Serialize, Deserialize)]
31pub enum EnvironmentManagerError {
32 #[error("Environment not found: {0}")]
33 NotFound(String),
34
35 #[error("Environment operation not supported: {0}")]
36 NotSupported(String),
37
38 #[error("Invalid environment request: {0}")]
39 InvalidRequest(String),
40
41 #[error("I/O error: {0}")]
42 Io(String),
43
44 #[error("Environment manager error: {0}")]
45 Other(String),
46}
47
48pub type EnvironmentManagerResult<T> = std::result::Result<T, EnvironmentManagerError>;
49
50impl From<std::io::Error> for EnvironmentManagerError {
51 fn from(err: std::io::Error) -> Self {
52 EnvironmentManagerError::Io(err.to_string())
53 }
54}
55
56impl From<WorkspaceError> for EnvironmentManagerError {
57 fn from(err: WorkspaceError) -> Self {
58 match err {
59 WorkspaceError::Io(message) => EnvironmentManagerError::Io(message),
60 other => EnvironmentManagerError::Other(other.to_string()),
61 }
62 }
63}
64
65#[derive(Error, Debug, Clone, Serialize, Deserialize)]
66pub enum WorkspaceManagerError {
67 #[error("Workspace not found: {0}")]
68 NotFound(String),
69
70 #[error("Workspace operation not supported: {0}")]
71 NotSupported(String),
72
73 #[error("Invalid workspace request: {0}")]
74 InvalidRequest(String),
75
76 #[error("I/O error: {0}")]
77 Io(String),
78
79 #[error("Workspace manager error: {0}")]
80 Other(String),
81}
82
83pub type WorkspaceManagerResult<T> = std::result::Result<T, WorkspaceManagerError>;
84
85impl From<std::io::Error> for WorkspaceManagerError {
86 fn from(err: std::io::Error) -> Self {
87 WorkspaceManagerError::Io(err.to_string())
88 }
89}
90
91impl From<WorkspaceError> for WorkspaceManagerError {
92 fn from(err: WorkspaceError) -> Self {
93 match err {
94 WorkspaceError::Io(message) => WorkspaceManagerError::Io(message),
95 other => WorkspaceManagerError::Other(other.to_string()),
96 }
97 }
98}
99
100impl From<tonic::transport::Error> for WorkspaceError {
101 fn from(err: tonic::transport::Error) -> Self {
102 WorkspaceError::Transport(err.to_string())
103 }
104}
105
106impl From<tonic::Status> for WorkspaceError {
107 fn from(err: tonic::Status) -> Self {
108 WorkspaceError::Status(err.to_string())
109 }
110}
111
112impl From<std::io::Error> for WorkspaceError {
113 fn from(err: std::io::Error) -> Self {
114 WorkspaceError::Io(err.to_string())
115 }
116}