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
use sqlx_core::Error as SqlxError;
use thiserror::Error as ThisError;

use crate::options::URL_SCHEME;

// Error returned for configuration failures caused by invalid URL connection strings.
#[derive(Debug, ThisError)]
pub enum ExaConfigError {
    #[error("no host provided")]
    MissingHost,
    #[error("could not resolve hostname")]
    CouldNotResolve(#[from] std::io::Error),
    #[error("multiple authentication methods provided")]
    MultipleAuthMethods,
    #[error("invalid URL scheme: {0}, expected: {}", URL_SCHEME)]
    InvalidUrlScheme(String),
    #[error("invalid connection parameter: {0}")]
    InvalidParameter(&'static str),
}

impl From<ExaConfigError> for SqlxError {
    fn from(value: ExaConfigError) -> Self {
        Self::Configuration(value.into())
    }
}