rsdbc_core/
error.rs

1use std::num::ParseIntError;
2use thiserror::Error;
3use url::Url;
4
5/// RSDBC Errors
6
7// TODO: do we need this error?
8#[derive(Error, Debug)]
9#[non_exhaustive]
10pub enum RsdbcErrors {
11    #[error("Configuration error: `{0}`")]
12    Configuration(String),
13
14    #[error("General error: `{0}`")]
15    General(String),
16
17    #[error("Unsupported error: `{0}`")]
18    Unsupported(String),
19
20    #[error("URL parse error: `{0}`")]
21    UrlParseError(#[from] url::ParseError),
22
23    #[error("Int parse error: `{0}`")]
24    ParseIntError(#[from] ParseIntError),
25
26    #[error("Unknown Database")]
27    UnknownDatabase,
28}
29
30impl RsdbcErrors {
31
32    // #[allow(dead_code)]
33    // #[inline]
34    // pub(crate) fn config(err: impl StdError + Send + Sync + 'static) -> Self {
35    //     Error::Configuration(err.into())
36    // }
37
38    #[allow(dead_code)]
39    #[inline]
40    pub fn config(err: String) -> Self {
41        RsdbcErrors::Configuration(err)
42    }
43}
44
45#[derive(Debug)]
46#[non_exhaustive]
47pub enum RsdbcError {
48    BadGrammar,
49    General,
50    NonTransient,
51    NonTransientResource,
52    PermissionDenied,
53    Rollback,
54    Timeout,
55    Transient,
56    TransientResource
57}
58
59// index out of bounds
60// IllegalArgumentException
61// NoSuchElementException
62
63// `Error::InvalidColumnType` if the underlying SQLite column  type is not a valid type as a source for `T`.
64// `Error::InvalidColumnIndex` if `idx` is outside the valid column range for this row.
65// `Error::InvalidColumnName` if `idx` is not a valid column name for this row.