geekorm_core/
error.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
//! Error Module for GeekORM

/// Error type for the crate
#[derive(Debug, thiserror::Error, Clone)]
pub enum Error {
    /// Database Connection Error
    #[error("Connection Error: {0}")]
    ConnectionError(String),
    /// Database Schema Error
    #[error("Schema Error: {0}")]
    SchemaError(String),
    /// Database Migration Error
    #[cfg(feature = "migrations")]
    #[error("{0}")]
    MigrationError(#[from] MigrationError),

    /// Query Builder Error
    #[error("QueryBuilderError: {0} ({1})")]
    QueryBuilderError(String, String),

    /// Column Not Found
    #[error("ColumnNotFound: Table({0}) {1}")]
    ColumnNotFound(String, String),

    /// Column Skipped
    #[error("Column Skipped")]
    ColumnSkipped,

    /// No Rows was found in the database for the query
    #[error("No Rows Found - Query: '{query}'")]
    NoRowsFound {
        /// Query
        query: String,
    },

    /// Pagination Error
    #[cfg(feature = "pagination")]
    #[error("Pagination Error: {0}")]
    PaginationError(String),

    /// Not Implemented
    #[error("Not Implemented")]
    NotImplemented,

    /// Error Hashing Password
    #[error("Error Hashing Password: {0}")]
    HashingError(String),

    /// Serde Error
    #[error("Serde Error: {0}")]
    SerdeError(String),

    /// Unknown Variant
    #[error("Unknown Variant {0}")]
    UnknownVariant(String),

    /// Unknown / Generic Error
    #[error("Unknown Error / Generic Error occurred")]
    Unknown,

    /// TOTP Error
    #[cfg(feature = "two-factor-auth")]
    #[error("TOTP Error: {0}")]
    TotpError(String),
    /// SystemTime Error
    #[error("SystemTime Error: {0}")]
    SystemTimeError(#[from] std::time::SystemTimeError),

    /// LibSQL Error
    #[cfg(feature = "libsql")]
    #[error(
        "LibSQL Error: {error}\n -> {query}\nPlease report this error to the GeekORM developers"
    )]
    LibSQLError {
        /// Error message
        error: String,
        /// Query
        query: String,
    },

    /// RuSQLite Error
    #[cfg(feature = "rusqlite")]
    #[error("RuSQLite Error occurred: {0}")]
    RuSQLiteError(String),

    /// Query Syntax Error
    #[error(
        "Query Syntax Error: {error}\n -> {query}\nPlease report this error to the GeekORM developers"
    )]
    QuerySyntaxError {
        /// Error message
        error: String,
        /// Query
        query: String,
    },
}

/// GeekORM Migration Error
#[cfg(feature = "migrations")]
#[derive(Debug, thiserror::Error, Clone)]
pub enum MigrationError {
    /// Missing Table (table name)
    #[error("Missing Table `{0}`")]
    MissingTable(String),
    /// Missing Column (table name, column name)
    #[error("Missing Column `{table}.{column}`")]
    MissingColumn {
        /// Table name
        table: String,
        /// Column name
        column: String,
    },
    /// Column Type Mismatch (table name, column name, feature)
    #[error("Column Type Mismatch `{table}.{column}`: {feature}")]
    ColumnTypeMismatch {
        /// Table name
        table: String,
        /// Column name
        column: String,
        /// Feature
        feature: String,
    },

    /// New Table (table name)
    #[error("New Table `{table}`")]
    NewTable {
        /// Table name
        table: String,
    },
    /// New Column (table name, column name)
    #[error("New Column `{table}.{column}`")]
    NewColumn {
        /// Table name
        table: String,
        /// Column name
        column: String,
    },

    /// Upgrade Error (reason)
    #[error("Upgrade Error: {0}")]
    UpgradeError(String),
    /// Missing Migration (migration name)
    #[error("Missing Migration: {0}")]
    MissingMigration(String),
}