multisql/data/value/
error.rs

1use {
2	crate::{Value, ValueType},
3	serde::Serialize,
4	std::fmt::Debug,
5	thiserror::Error,
6};
7
8#[derive(Error, Serialize, Debug, PartialEq)]
9pub enum ValueError {
10	#[error("literal: {literal} is incompatible with data type: {data_type}")]
11	IncompatibleLiteralForDataType { data_type: String, literal: String },
12
13	#[error("incompatible data type, data type: {data_type}, value: {value}")]
14	IncompatibleDataType { data_type: String, value: String },
15
16	#[error("null value on not null field")]
17	NullValueOnNotNullField,
18
19	#[error("failed to parse number")]
20	FailedToParseNumber,
21
22	#[error("unreachable failure on parsing number")]
23	UnreachableNumberParsing,
24
25	#[error("floating columns cannot be set to unique constraint")]
26	ConflictOnFloatWithUniqueConstraint,
27
28	#[error(
29		"number of function parameters not matching (expected: {expected:?}, found: {found:?})"
30	)]
31	NumberOfFunctionParamsNotMatching { expected: usize, found: usize },
32
33	#[error("conversion rule is not accepted for this type")]
34	InvalidConversionRule,
35
36	#[error("impossible cast")]
37	ImpossibleCast, // Bad error-- phase out
38	#[error("failed to cast {0:?} into {1:?}")]
39	FailedCast(Value, ValueType),
40
41	#[error("date time failed to parse: {0}")]
42	DateTimeParseError(String),
43	#[error("failed to parse {0:?} as {1}")]
44	ParseError(Value, &'static str),
45	#[error("something went wrong with date math")]
46	DateError, // Should avoid throwing
47	#[error("timestamp error: {0}")]
48	SpecifiedTimestampError(String), // Should avoid throwing
49
50	#[error("cannot convert {0:?} into {1}")]
51	CannotConvert(Value, &'static str),
52
53	#[error("{1} only supports numeric values, found {0:?}")]
54	OnlySupportsNumeric(Value, &'static str),
55	#[error("{1} only supports boolean values, found {0:?}")]
56	OnlySupportsBoolean(Value, &'static str),
57	#[error("bad input: {0:?}")]
58	BadInput(Value),
59
60	#[error("unimplemented literal type")]
61	UnimplementedLiteralType,
62	#[error("unimplemented cast")]
63	UnimplementedCast,
64	#[error("unimplemented convert")]
65	UnimplementedConvert,
66	#[error("unreachable literal cast from number to integer: {0}")]
67	UnreachableLiteralCastFromNumberToInteger(String),
68	#[error("unimplemented literal cast: {literal} as {data_type}")]
69	UnimplementedLiteralCast { data_type: String, literal: String },
70}