Skip to content

Commit 3d3ddb0

Browse files
committed
fix(query): add From<GraphError> and From<SpoError> for QueryError
From<GraphError>: maps ParseError→ParseError, PlanError→PlanError, ConfigError→PlanError, ExecutionError→ExecutionError, UnsupportedFeature→UnsupportedFeature, InvalidPattern→InvalidPattern. From<SpoError>: maps all variants via Display → SpoError { message }. Verified: .parse().unwrap() in cypher.rs already uses .map_err(). https://claude.ai/code/session_018L7tAcJ9ppReFdcjhYjTcb
1 parent 2e22664 commit 3d3ddb0

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

src/query/error.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,48 @@ impl From<datafusion::error::DataFusionError> for QueryError {
152152
}
153153
}
154154

155+
impl From<crate::graph::spo::sparse::SpoError> for QueryError {
156+
fn from(source: crate::graph::spo::sparse::SpoError) -> Self {
157+
Self::SpoError {
158+
message: source.to_string(),
159+
location: Location::new(file!(), line!(), column!()),
160+
}
161+
}
162+
}
163+
164+
impl From<crate::query::lance_parser::error::GraphError> for QueryError {
165+
fn from(source: crate::query::lance_parser::error::GraphError) -> Self {
166+
use crate::query::lance_parser::error::GraphError;
167+
match source {
168+
GraphError::ParseError { message, position, location } => Self::ParseError {
169+
message,
170+
position,
171+
location,
172+
},
173+
GraphError::PlanError { message, location } => Self::PlanError {
174+
message,
175+
location,
176+
},
177+
GraphError::ExecutionError { message, location } => Self::ExecutionError {
178+
message,
179+
location,
180+
},
181+
GraphError::ConfigError { message, location } => Self::PlanError {
182+
message,
183+
location,
184+
},
185+
GraphError::UnsupportedFeature { feature, location } => Self::UnsupportedFeature {
186+
feature,
187+
location,
188+
},
189+
GraphError::InvalidPattern { message, location } => Self::InvalidPattern {
190+
message,
191+
location,
192+
},
193+
}
194+
}
195+
}
196+
155197
#[cfg(test)]
156198
mod tests {
157199
use super::*;

0 commit comments

Comments
 (0)