use thiserror::Error;
#[derive(Debug, Error)]
#[error("parse error at position {position}: {kind}")]
pub struct ParseError {
pub kind: ParseErrorKind,
pub position: usize,
}
#[derive(Debug, Error)]
pub enum ParseErrorKind {
#[error("unexpected end of input")]
UnexpectedEof,
#[error("{0}")]
SyntaxError(String),
}
impl ParseError {
pub const fn new(kind: ParseErrorKind, position: usize) -> Self {
Self { kind, position }
}
}
#[derive(Debug, Error)]
pub enum QueryError {
#[error("parse error: {0}")]
Parse(#[from] ParseError),
#[error("type error: {0}")]
Type(String),
#[error("unknown column: {0}")]
UnknownColumn(String),
#[error("unknown function: {0}")]
UnknownFunction(String),
#[error("invalid arguments for function {0}: {1}")]
InvalidArguments(String, String),
#[error("aggregation error: {0}")]
Aggregation(String),
#[error("evaluation error: {0}")]
Evaluation(String),
}