1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, EventualiError>;
4
5#[derive(Error, Debug)]
6pub enum EventualiError {
7 #[error("Database error: {0}")]
8 Database(#[from] sqlx::Error),
9
10 #[error("Serialization error: {0}")]
11 Serialization(#[from] serde_json::Error),
12
13 #[error("Protobuf error: {0}")]
14 Protobuf(#[from] prost::DecodeError),
15
16 #[error("Aggregate not found: {id}")]
17 AggregateNotFound { id: String },
18
19 #[error("Optimistic concurrency error: expected version {expected}, got {actual}")]
20 OptimisticConcurrency { expected: i64, actual: i64 },
21
22 #[error("Invalid event data: {0}")]
23 InvalidEventData(String),
24
25 #[error("Configuration error: {0}")]
26 Configuration(String),
27
28 #[error("IO error: {0}")]
29 Io(#[from] std::io::Error),
30
31 #[error("Encryption error: {0}")]
32 Encryption(String),
33
34 #[error("Tenant error: {0}")]
35 Tenant(String),
36
37 #[error("Observability error: {0}")]
38 ObservabilityError(String),
39
40 #[error("Validation error: {0}")]
41 Validation(String),
42
43 #[error("Authentication error: {0}")]
44 Authentication(String),
45
46 #[error("Authorization error: {0}")]
47 Authorization(String),
48
49 #[error("Invalid state: {0}")]
50 InvalidState(String),
51
52 #[error("Backpressure applied: {0}")]
53 BackpressureApplied(String),
54
55 #[error("Batch processing error: {0}")]
56 BatchProcessingError(String),
57
58 #[error("Database error: {0}")]
59 DatabaseError(String),
60}