Skip to main content

canvas_core/
error.rs

1//! Error types for canvas operations.
2
3use thiserror::Error;
4
5/// Result type for canvas operations.
6pub type CanvasResult<T> = Result<T, CanvasError>;
7
8/// Errors that can occur in canvas operations.
9#[derive(Debug, Error)]
10pub enum CanvasError {
11    /// Element not found in scene.
12    #[error("Element not found: {0}")]
13    ElementNotFound(String),
14
15    /// Invalid element operation.
16    #[error("Invalid operation on element: {0}")]
17    InvalidOperation(String),
18
19    /// Scene serialization/deserialization error.
20    #[error("Serialization error: {0}")]
21    Serialization(#[from] serde_json::Error),
22
23    /// Connection to AI/MCP lost.
24    #[error("Connection lost: {0}")]
25    ConnectionLost(String),
26
27    /// Resource loading failed.
28    #[error("Failed to load resource: {0}")]
29    ResourceLoad(String),
30
31    /// Rendering error.
32    #[error("Rendering error: {0}")]
33    Render(String),
34}