rustledger_query/
error.rs1use thiserror::Error;
4
5#[derive(Debug, Error)]
7#[error("parse error at position {position}: {kind}")]
8pub struct ParseError {
9 pub kind: ParseErrorKind,
11 pub position: usize,
13}
14
15#[derive(Debug, Error)]
17pub enum ParseErrorKind {
18 #[error("unexpected end of input")]
20 UnexpectedEof,
21 #[error("{0}")]
23 SyntaxError(String),
24}
25
26impl ParseError {
27 pub const fn new(kind: ParseErrorKind, position: usize) -> Self {
29 Self { kind, position }
30 }
31}
32
33#[derive(Debug, Error)]
35pub enum QueryError {
36 #[error("parse error: {0}")]
38 Parse(#[from] ParseError),
39 #[error("type error: {0}")]
41 Type(String),
42 #[error("unknown column: {0}")]
44 UnknownColumn(String),
45 #[error("unknown function: {0}")]
47 UnknownFunction(String),
48 #[error("invalid arguments for function {0}: {1}")]
50 InvalidArguments(String, String),
51 #[error("aggregation error: {0}")]
53 Aggregation(String),
54 #[error("evaluation error: {0}")]
56 Evaluation(String),
57}