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
use std::num::{ParseFloatError, ParseIntError};
use crate::sqlx_types::Error as SqlxError;
pub type DiscoveryResult<T> = Result<T, SqliteDiscoveryError>;
#[derive(Debug)]
pub enum SqliteDiscoveryError {
ParseIntError,
ParseFloatError,
SqlxError(SqlxError),
NoIndexesFound,
}
impl From<ParseIntError> for SqliteDiscoveryError {
fn from(_: ParseIntError) -> Self {
SqliteDiscoveryError::ParseIntError
}
}
impl From<ParseFloatError> for SqliteDiscoveryError {
fn from(_: ParseFloatError) -> Self {
SqliteDiscoveryError::ParseFloatError
}
}
impl From<SqlxError> for SqliteDiscoveryError {
fn from(error: SqlxError) -> Self {
SqliteDiscoveryError::SqlxError(error)
}
}
impl std::error::Error for SqliteDiscoveryError {}
impl std::fmt::Display for SqliteDiscoveryError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
SqliteDiscoveryError::ParseIntError => write!(f, "Parse Integer Error"),
SqliteDiscoveryError::ParseFloatError => write!(f, "Parse Float Error Error"),
SqliteDiscoveryError::SqlxError(e) => write!(f, "SQLx Error: {:?}", e),
SqliteDiscoveryError::NoIndexesFound => write!(f, "No Indexes Found Error"),
}
}
}