lumus_sql_builder/
errors.rs

1#[derive(Debug)]
2pub enum SqlBuilderError {
3    EmptyTableName,
4    EmptyColumnName,
5    EmptyColumnAndValue,
6    EmptyValue,
7    NoColumnsSpecified,
8    InvalidColumnType,
9    InvalidQuery,
10    EmptyCondition,
11    EmptyOnClause,
12}
13
14impl core::fmt::Display for SqlBuilderError {
15    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
16        match self {
17            Self::EmptyTableName => write!(f, "Table name cannot be empty."),
18            Self::EmptyColumnName => write!(f, "Column name cannot be empty."),
19            Self::EmptyColumnAndValue => write!(
20                f,
21                "The column and the value to be inserted cannot be empty."
22            ),
23            Self::EmptyValue => write!(f, "The value cannot be empty."),
24            Self::NoColumnsSpecified => write!(f, "No columns specified for table."),
25            Self::InvalidColumnType => {
26                write!(f, "The specified column type is invalid.")
27            }
28            Self::InvalidQuery => write!(f, "The query is invalid."),
29            Self::EmptyCondition => write!(f, "The conditions cannot be empty."),
30            Self::EmptyOnClause => write!(f, "The on clause cannot be empty."),
31        }
32    }
33}
34
35impl std::error::Error for SqlBuilderError {}