reifydb_sub_server/
execute.rs1use std::{error, fmt, sync::Arc};
5
6use reifydb_value::error::Diagnostic;
7
8#[derive(Debug)]
9pub enum ExecuteError {
10 Timeout,
11
12 Cancelled,
13
14 Disconnected,
15
16 Engine {
17 diagnostic: Arc<Diagnostic>,
18
19 rql: String,
20 },
21
22 Rejected {
23 code: String,
24
25 message: String,
26 },
27}
28
29impl fmt::Display for ExecuteError {
30 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
31 match self {
32 ExecuteError::Timeout => write!(f, "Query execution timed out"),
33 ExecuteError::Cancelled => write!(f, "Query was cancelled"),
34 ExecuteError::Disconnected => write!(f, "Query stream disconnected unexpectedly"),
35 ExecuteError::Engine {
36 diagnostic,
37 ..
38 } => write!(f, "Engine error: {}", diagnostic.message),
39 ExecuteError::Rejected {
40 code,
41 message,
42 } => write!(f, "Rejected [{}]: {}", code, message),
43 }
44 }
45}
46
47impl error::Error for ExecuteError {}
48
49pub type ExecuteResult<T> = Result<T, ExecuteError>;