1use std::path::PathBuf;
4
5use venus_core::graph::CellId;
6
7#[derive(Debug, thiserror::Error)]
9pub enum ServerError {
10 #[error("IO error at {path}: {message}")]
12 Io { path: PathBuf, message: String },
13
14 #[error("Core error: {0}")]
16 Core(#[from] venus_core::Error),
17
18 #[error("Cell not found: {0:?}")]
20 CellNotFound(CellId),
21
22 #[error("Execution already in progress")]
24 ExecutionInProgress,
25
26 #[error("WebSocket error: {0}")]
28 WebSocket(String),
29
30 #[error("JSON error: {0}")]
32 Json(#[from] serde_json::Error),
33
34 #[error("File watch error: {0}")]
36 Watch(String),
37
38 #[error("Execution aborted")]
40 ExecutionAborted,
41
42 #[error("Execution timed out")]
44 ExecutionTimeout,
45
46 #[error("Invalid operation: {0}")]
48 InvalidOperation(String),
49}
50
51impl From<std::io::Error> for ServerError {
52 fn from(e: std::io::Error) -> Self {
53 Self::Io {
54 path: PathBuf::new(),
55 message: e.to_string(),
56 }
57 }
58}
59
60pub type ServerResult<T> = Result<T, ServerError>;