Skip to main content

oximedia_review/
error.rs

1//! Error types for review operations.
2
3use thiserror::Error;
4
5/// Result type for review operations.
6pub type ReviewResult<T> = Result<T, ReviewError>;
7
8/// Errors that can occur during review operations.
9#[derive(Debug, Error)]
10pub enum ReviewError {
11    /// Session not found.
12    #[error("Session not found: {0}")]
13    SessionNotFound(String),
14
15    /// Comment not found.
16    #[error("Comment not found: {0}")]
17    CommentNotFound(String),
18
19    /// Drawing not found.
20    #[error("Drawing not found: {0}")]
21    DrawingNotFound(String),
22
23    /// Task not found.
24    #[error("Task not found: {0}")]
25    TaskNotFound(String),
26
27    /// Version not found.
28    #[error("Version not found: {0}")]
29    VersionNotFound(String),
30
31    /// User not found.
32    #[error("User not found: {0}")]
33    UserNotFound(String),
34
35    /// Permission denied.
36    #[error("Permission denied: {0}")]
37    PermissionDenied(String),
38
39    /// Invalid frame number.
40    #[error("Invalid frame number: {0}")]
41    InvalidFrame(i64),
42
43    /// Invalid state transition.
44    #[error("Invalid state transition: {0}")]
45    InvalidStateTransition(String),
46
47    /// Session already closed.
48    #[error("Session already closed")]
49    SessionClosed,
50
51    /// Comment already resolved.
52    #[error("Comment already resolved")]
53    CommentAlreadyResolved,
54
55    /// Approval already submitted.
56    #[error("Approval already submitted")]
57    ApprovalAlreadySubmitted,
58
59    /// Workflow validation error.
60    #[error("Workflow validation error: {0}")]
61    WorkflowValidation(String),
62
63    /// Export error.
64    #[error("Export error: {0}")]
65    ExportError(String),
66
67    /// Notification error.
68    #[error("Notification error: {0}")]
69    NotificationError(String),
70
71    /// Real-time sync error.
72    #[error("Real-time sync error: {0}")]
73    SyncError(String),
74
75    /// Invalid configuration.
76    #[error("Invalid configuration: {0}")]
77    InvalidConfig(String),
78
79    /// IO error.
80    #[error("IO error: {0}")]
81    Io(#[from] std::io::Error),
82
83    /// Serialization error.
84    #[error("Serialization error: {0}")]
85    Serialization(#[from] serde_json::Error),
86
87    /// Other error.
88    #[error("Other error: {0}")]
89    Other(String),
90}
91
92#[cfg(test)]
93mod tests {
94    use super::*;
95
96    #[test]
97    fn test_error_display() {
98        let err = ReviewError::SessionNotFound("session-123".to_string());
99        assert_eq!(err.to_string(), "Session not found: session-123");
100    }
101
102    #[test]
103    fn test_error_from_io() {
104        let io_err = std::io::Error::new(std::io::ErrorKind::NotFound, "file not found");
105        let err: ReviewError = io_err.into();
106        assert!(matches!(err, ReviewError::Io(_)));
107    }
108}