geekorm_core/
error.rs

1//! Error Module for GeekORM
2
3/// Error type for the crate
4#[derive(Debug, thiserror::Error, Clone)]
5pub enum Error {
6    /// Database Connection Error
7    #[error("Connection Error: {0}")]
8    ConnectionError(String),
9    /// Database Schema Error
10    #[error("Schema Error: {0}")]
11    SchemaError(String),
12    /// Database Migration Error
13    #[cfg(feature = "migrations")]
14    #[error("{0}")]
15    MigrationError(#[from] MigrationError),
16
17    /// Query Builder Error
18    #[error("QueryBuilderError: {0} ({1})")]
19    QueryBuilderError(String, String),
20
21    /// Column Not Found
22    #[error("ColumnNotFound: Table({0}) {1}")]
23    ColumnNotFound(String, String),
24
25    /// Column Skipped
26    #[error("Column Skipped")]
27    ColumnSkipped,
28
29    /// No Rows was found in the database for the query
30    #[error("No Rows Found - Query: '{query}'")]
31    NoRowsFound {
32        /// Query
33        query: String,
34    },
35
36    /// Pagination Error
37    #[cfg(feature = "pagination")]
38    #[error("Pagination Error: {0}")]
39    PaginationError(String),
40
41    /// Not Implemented
42    #[error("Not Implemented")]
43    NotImplemented,
44
45    /// Error Hashing Password
46    #[error("Error Hashing Password: {0}")]
47    HashingError(String),
48
49    /// Serde Error
50    #[error("Serde Error: {0}")]
51    SerdeError(String),
52
53    /// Unknown Variant
54    #[error("Unknown Variant {0}")]
55    UnknownVariant(String),
56
57    /// Unknown / Generic Error
58    #[error("Unknown Error / Generic Error occurred")]
59    Unknown,
60
61    /// TOTP Error
62    #[cfg(feature = "two-factor-auth")]
63    #[error("TOTP Error: {0}")]
64    TotpError(String),
65    /// SystemTime Error
66    #[error("SystemTime Error: {0}")]
67    SystemTimeError(#[from] std::time::SystemTimeError),
68
69    /// LibSQL Error
70    #[cfg(feature = "libsql")]
71    #[error(
72        "LibSQL Error: {error}\n -> {query}\nPlease report this error to the GeekORM developers"
73    )]
74    LibSQLError {
75        /// Error message
76        error: String,
77        /// Query
78        query: String,
79    },
80
81    /// RuSQLite Error
82    #[cfg(feature = "rusqlite")]
83    #[error("RuSQLite Error occurred: {0}")]
84    RuSQLiteError(String),
85
86    /// Query Syntax Error
87    #[error(
88        "Query Syntax Error: {error}\n -> {query}\nPlease report this error to the GeekORM developers"
89    )]
90    QuerySyntaxError {
91        /// Error message
92        error: String,
93        /// Query
94        query: String,
95    },
96}
97
98/// GeekORM Migration Error
99#[cfg(feature = "migrations")]
100#[derive(Debug, thiserror::Error, Clone)]
101pub enum MigrationError {
102    /// Missing Table (table name)
103    #[error("Missing Table `{0}`")]
104    MissingTable(String),
105    /// Missing Column (table name, column name)
106    #[error("Missing Column `{table}.{column}`")]
107    MissingColumn {
108        /// Table name
109        table: String,
110        /// Column name
111        column: String,
112    },
113    /// Column Type Mismatch (table name, column name, feature)
114    #[error("Column Type Mismatch `{table}.{column}`: {feature}")]
115    ColumnTypeMismatch {
116        /// Table name
117        table: String,
118        /// Column name
119        column: String,
120        /// Feature
121        feature: String,
122    },
123
124    /// New Table (table name)
125    #[error("New Table `{table}`")]
126    NewTable {
127        /// Table name
128        table: String,
129    },
130    /// New Column (table name, column name)
131    #[error("New Column `{table}.{column}`")]
132    NewColumn {
133        /// Table name
134        table: String,
135        /// Column name
136        column: String,
137    },
138
139    /// Upgrade Error (reason)
140    #[error("Upgrade Error: {0}")]
141    UpgradeError(String),
142    /// Missing Migration (migration name)
143    #[error("Missing Migration: {0}")]
144    MissingMigration(String),
145}