1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, FlightSqlError>;
4
5#[derive(Debug, Error)]
6pub enum FlightSqlError {
7 #[error("Redis error: {0}")]
8 Redis(#[from] redis::RedisError),
9
10 #[error("Arrow error: {0}")]
11 Arrow(#[from] arrow::error::ArrowError),
12
13 #[error("Arrow Flight error: {0}")]
14 Flight(#[from] arrow_flight::error::FlightError),
15
16 #[error("FalkorDB error: {0}")]
17 Falkor(#[from] graphar_falkordb::FalkorError),
18
19 #[error("GraphAr error: {0}")]
20 Graphar(#[from] graphar::GraphArError),
21
22 #[error("Iceberg/skade error: {0}")]
23 Skade(String),
24
25 #[error("Schema not registered for key '{0}' — call SchemaRegistry::register first")]
26 UnregisteredSchema(String),
27
28 #[error("Unexpected FalkorDB response shape: {0}")]
29 MalformedResponse(String),
30
31 #[error(
32 "DoPut command unrecognised: '{0}' (expected VERTICES:<label> or EDGES:<src>:<type>:<dst>)"
33 )]
34 UnknownPutCommand(String),
35
36 #[error("Column count mismatch: schema has {schema} columns but row has {row}")]
37 ColumnCountMismatch { schema: usize, row: usize },
38
39 #[error("Transport error: {0}")]
40 Transport(#[from] tonic::transport::Error),
41}
42
43impl From<FlightSqlError> for tonic::Status {
44 fn from(e: FlightSqlError) -> Self {
45 match &e {
46 FlightSqlError::UnregisteredSchema(_) => tonic::Status::not_found(e.to_string()),
47 FlightSqlError::UnknownPutCommand(_) => tonic::Status::invalid_argument(e.to_string()),
48 _ => tonic::Status::internal(e.to_string()),
49 }
50 }
51}