1use std::{fmt, io};
2use thiserror::Error;
3
4#[derive(Error, Debug)]
5pub enum Error {
6 #[error("I/O error: {0}")]
7 Io(#[from] io::Error),
8
9 #[error("Arrow error: {0}")]
10 Arrow(#[from] arrow::error::ArrowError),
11
12 #[error("Invalid argument: {0}")]
13 InvalidArgumentError(String),
14
15 #[error("Storage key not found")]
16 NotFound,
17
18 #[error("An internal operation failed: {0}")]
19 Internal(String),
20
21 #[error("expression cast error: {0}")]
22 ExprCast(String),
23
24 #[error("predicate build error: {0}")]
25 PredicateBuild(String),
26
27 #[error("table id {0} is reserved for system catalogs")]
28 ReservedTableId(u16),
29}
30
31impl Error {
32 #[inline]
33 pub fn expr_cast<E: fmt::Display>(err: E) -> Self {
34 Error::ExprCast(err.to_string())
35 }
36
37 #[inline]
38 pub fn predicate_build<E: fmt::Display>(err: E) -> Self {
39 Error::PredicateBuild(err.to_string())
40 }
41
42 #[inline]
43 pub fn reserved_table_id(table_id: u16) -> Self {
44 Error::ReservedTableId(table_id)
45 }
46}