database_schema/
error.rs

1//! Error types for the library.
2
3/// Error types for the library.
4#[non_exhaustive]
5#[derive(Debug, thiserror::Error)]
6pub enum Error {
7    #[error("IO error: {0}")]
8    /// Any kind of IO error
9    IOError(#[from] std::io::Error),
10    #[error("Command run error: {0}")]
11    /// Any kind of error when running a command
12    CommandRunError(String),
13    #[cfg(feature = "sqlx")]
14    #[error("DB error: {0}")]
15    /// Any kind of database engine related error
16    DBError(#[from] sqlx::Error),
17    #[cfg(feature = "diesel")]
18    #[error("DB error: {0}")]
19    /// Any kind of database engine related error
20    DBError(#[from] diesel::result::Error),
21    #[cfg(feature = "diesel")]
22    #[error("DB error: {0}")]
23    /// Any connection error when connecting to the database in `diesel`
24    DBConnectionError(#[from] diesel::ConnectionError),
25    #[cfg(feature = "diesel")]
26    #[error("DB error: {0}")]
27    /// Any connection error when running migrations in `diesel`
28    MigrationError(#[from] diesel_migrations::MigrationError),
29    #[cfg(any(feature = "mysql", feature = "postgres"))]
30    #[error("Unable to extract database name from connection string")]
31    /// Extracting the database name from the connection string failed
32    ExtractDatabaseNameError,
33    #[cfg(any(feature = "mysql", feature = "postgres"))]
34    #[error("Uri configuration error: {0}")]
35    /// Error when parsing the connection string
36    UriConfiguration(String),
37    #[cfg(any(feature = "mysql", feature = "postgres"))]
38    #[error("Uri configuration encoding error: {0}")]
39    /// Error when decoding parts of the connection string
40    UriConfigurationDecoding(#[from] core::str::Utf8Error),
41}