1use serde::{Deserialize, Serialize};
2use std::fmt;
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
9pub enum VtxError {
10 DatabaseError(String),
12
13 SerializationError(String),
15
16 AuthDenied(u16),
18
19 PermissionDenied(String),
21
22 NotFound(String),
24
25 Internal(String),
27}
28
29impl fmt::Display for VtxError {
30 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
31 match self {
32 VtxError::DatabaseError(msg) => write!(f, "Database error: {}", msg),
33 VtxError::SerializationError(msg) => write!(f, "Data serialization error: {}", msg),
34 VtxError::AuthDenied(code) => write!(f, "Authentication denied (Code: {})", code),
35 VtxError::PermissionDenied(msg) => write!(f, "Permission denied: {}", msg),
36 VtxError::NotFound(msg) => write!(f, "Resource not found: {}", msg),
37 VtxError::Internal(msg) => write!(f, "Internal error: {}", msg),
38 }
39 }
40}
41
42impl std::error::Error for VtxError {}
43
44pub type VtxResult<T> = Result<T, VtxError>;