venus_server/
error.rs

1//! Error types for Venus server.
2
3use std::path::PathBuf;
4
5use venus_core::graph::CellId;
6
7/// Server error type.
8#[derive(Debug, thiserror::Error)]
9pub enum ServerError {
10    /// IO error.
11    #[error("IO error at {path}: {message}")]
12    Io { path: PathBuf, message: String },
13
14    /// Venus core error.
15    #[error("Core error: {0}")]
16    Core(#[from] venus_core::Error),
17
18    /// Cell not found.
19    #[error("Cell not found: {0:?}")]
20    CellNotFound(CellId),
21
22    /// Execution already in progress.
23    #[error("Execution already in progress")]
24    ExecutionInProgress,
25
26    /// WebSocket error.
27    #[error("WebSocket error: {0}")]
28    WebSocket(String),
29
30    /// JSON serialization error.
31    #[error("JSON error: {0}")]
32    Json(#[from] serde_json::Error),
33
34    /// Watch error.
35    #[error("File watch error: {0}")]
36    Watch(String),
37
38    /// Execution was aborted by user request.
39    #[error("Execution aborted")]
40    ExecutionAborted,
41
42    /// Execution timed out.
43    #[error("Execution timed out")]
44    ExecutionTimeout,
45
46    /// Invalid operation.
47    #[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
60/// Result type for server operations.
61pub type ServerResult<T> = Result<T, ServerError>;