use dataflow_rs::engine::error::DataflowError;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum QueryError {
UnsupportedInQuery { op: String, at: String },
NotRepresentable { what: String, at: String },
InvalidEnvelope(String),
InvalidField { field: String, at: String },
MissingParam { name: String, at: String },
UnknownRelation { relation: String, at: String },
LimitExceeded { requested: u64, max: u64 },
FeatureUnsupportedByTarget { feature: String, target: String },
}
impl std::fmt::Display for QueryError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
QueryError::UnsupportedInQuery { op, at } => {
write!(f, "operator '{op}' is not supported in a query (at {at})")
}
QueryError::NotRepresentable { what, at } => {
write!(f, "{what} has no portable form in v1 (at {at})")
}
QueryError::InvalidEnvelope(msg) => write!(f, "invalid query envelope: {msg}"),
QueryError::InvalidField { field, at } => {
write!(f, "invalid field reference '{field}' (at {at})")
}
QueryError::MissingParam { name, at } => {
write!(f, "query references undefined param '{name}' (at {at})")
}
QueryError::UnknownRelation { relation, at } => {
write!(f, "unknown relation '{relation}' (at {at})")
}
QueryError::FeatureUnsupportedByTarget { feature, target } => {
write!(f, "{feature} is not supported by the {target} backend")
}
QueryError::LimitExceeded { requested, max } => {
write!(
f,
"requested limit {requested} exceeds the configured maximum {max}"
)
}
}
}
}
impl std::error::Error for QueryError {}
impl From<QueryError> for DataflowError {
fn from(e: QueryError) -> Self {
DataflowError::Validation(e.to_string())
}
}