proof_of_sql/sql/
error.rs1use crate::base::{
2 database::ColumnType,
3 math::decimal::{DecimalError, IntermediateDecimalError},
4 proof::PlaceholderError,
5};
6use alloc::string::{String, ToString};
7use core::result::Result;
8use snafu::Snafu;
9
10#[derive(Snafu, Debug, PartialEq, Eq)]
13pub enum AnalyzeError {
14 #[snafu(display("Expected '{expected}' but found '{actual}'"))]
15 InvalidDataType {
17 expected: ColumnType,
19 actual: ColumnType,
21 },
22
23 #[snafu(display("Left side has '{left_type}' type but right side has '{right_type}' type"))]
24 DataTypeMismatch {
26 left_type: String,
28 right_type: String,
30 },
31
32 #[snafu(display("Columns have different lengths: {len_a} != {len_b}"))]
33 DifferentColumnLength {
35 len_a: usize,
37 len_b: usize,
39 },
40
41 #[snafu(transparent)]
42 DecimalConversionError {
44 source: DecimalError,
46 },
47
48 #[snafu(transparent)]
49 PlaceholderError {
51 source: PlaceholderError,
53 },
54}
55
56impl From<AnalyzeError> for String {
57 fn from(error: AnalyzeError) -> Self {
58 error.to_string()
59 }
60}
61
62impl From<IntermediateDecimalError> for AnalyzeError {
63 fn from(err: IntermediateDecimalError) -> AnalyzeError {
64 AnalyzeError::DecimalConversionError {
65 source: DecimalError::IntermediateDecimalConversionError { source: err },
66 }
67 }
68}
69
70pub type AnalyzeResult<T> = Result<T, AnalyzeError>;