1use thiserror::Error;
6
7pub type StreamResult<T> = Result<T, StreamError>;
9
10#[derive(Error, Debug)]
12pub enum StreamError {
13 #[error("Backend error: {0}")]
14 Backend(String),
15
16 #[error("Connection error: {0}")]
17 Connection(String),
18
19 #[error("Serialization error: {0}")]
20 Serialization(String),
21
22 #[error("Deserialization error: {0}")]
23 Deserialization(String),
24
25 #[error("Configuration error: {0}")]
26 Configuration(String),
27
28 #[error("Topic not found: {0}")]
29 TopicNotFound(String),
30
31 #[error("Consumer group error: {0}")]
32 ConsumerGroup(String),
33
34 #[error("Offset error: {0}")]
35 Offset(String),
36
37 #[error("Timeout error: {0}")]
38 Timeout(String),
39
40 #[error("Circuit breaker open")]
41 CircuitBreakerOpen,
42
43 #[error("Feature not supported: {0}")]
44 NotSupported(String),
45
46 #[error("Not connected: {0}")]
47 NotConnected(String),
48
49 #[error("Topic creation error: {0}")]
50 TopicCreation(String),
51
52 #[error("Topic deletion error: {0}")]
53 TopicDeletion(String),
54
55 #[error("Topic list error: {0}")]
56 TopicList(String),
57
58 #[error("Send error: {0}")]
59 Send(String),
60
61 #[error("Receive error: {0}")]
62 Receive(String),
63
64 #[error("Offset commit error: {0}")]
65 OffsetCommit(String),
66
67 #[error("Commit error: {0}")]
68 CommitError(String),
69
70 #[error("Seek error: {0}")]
71 SeekError(String),
72
73 #[error("Topic metadata error: {0}")]
74 TopicMetadata(String),
75
76 #[error("Unsupported operation: {0}")]
77 UnsupportedOperation(String),
78
79 #[error("Quantum processing error: {0}")]
80 QuantumProcessing(String),
81
82 #[error("Quantum error correction failed: {code_type:?}, error: {error}")]
83 QuantumErrorCorrection { code_type: String, error: String },
84
85 #[error("Quantum decoherence detected: coherence_time: {coherence_time:?}")]
86 QuantumDecoherence { coherence_time: std::time::Duration },
87
88 #[error("Biological computation error: {0}")]
89 BiologicalComputation(String),
90
91 #[error("DNA encoding error: sequence_length: {length}, gc_content: {gc_content}")]
92 DNAEncoding { length: usize, gc_content: f64 },
93
94 #[error("Cellular automaton error: generation: {generation}, error: {error}")]
95 CellularAutomaton { generation: usize, error: String },
96
97 #[error("Consciousness processing error: level: {level:?}, error: {error}")]
98 ConsciousnessProcessing { level: String, error: String },
99
100 #[error("Neural network error: {0}")]
101 NeuralNetwork(String),
102
103 #[error("Time travel query error: {0}")]
104 TimeTravelQuery(String),
105
106 #[error("WASM edge computing error: {0}")]
107 WasmEdgeComputing(String),
108
109 #[error("Invalid WASM module: {0}")]
110 InvalidModule(String),
111
112 #[error("Invalid signature: {0}")]
113 InvalidSignature(String),
114
115 #[error("Invalid operation: {0}")]
116 InvalidOperation(String),
117
118 #[error("Performance optimization error: {metric}, expected: {expected}, actual: {actual}")]
119 PerformanceOptimization {
120 metric: String,
121 expected: f64,
122 actual: f64,
123 },
124
125 #[error("Other error: {0}")]
126 Other(String),
127
128 #[error("Not found: {0}")]
129 NotFound(String),
130
131 #[error("Invalid input: {0}")]
132 InvalidInput(String),
133
134 #[error("I/O error: {0}")]
135 Io(String),
136
137 #[error("Resource exhausted: {0}")]
138 ResourceExhausted(String),
139}
140
141impl From<std::io::Error> for StreamError {
142 fn from(err: std::io::Error) -> Self {
143 StreamError::Backend(err.to_string())
144 }
145}
146
147impl From<serde_json::Error> for StreamError {
148 fn from(err: serde_json::Error) -> Self {
149 StreamError::Serialization(err.to_string())
150 }
151}
152
153impl From<anyhow::Error> for StreamError {
154 fn from(err: anyhow::Error) -> Self {
155 StreamError::Other(err.to_string())
156 }
157}