1pub type Result<T> = std::result::Result<T, Error>;
2pub type DeriveSqlResult<T> = std::result::Result<T, Error>;
3
4#[derive(thiserror::Error, Debug)]
5pub enum Error {
6 #[error("Not implemented yet")]
7 NotImplemented,
8 #[error("`rowid` or similar approach is not supported for MySQL queries. Rewrite your query to elliminate its use")]
9 MySQLRowIdNotSupported,
10 #[error("Update statement with limit and/or offset is not supported")]
11 UpdateWithLimitOffsetNotSupported,
12 #[error("Unable to convert from PostgreSQL type `{0}`")]
13 PostgreSQLInvalidConversion(String),
14 #[error("Type `{1}` is not supported in SQL flavor `{0}`")]
15 SqlTypeNotSupported(String, String),
16 #[error(transparent)]
17 FromChronoParseError(#[from] chrono::ParseError),
18 #[error(transparent)]
19 FromUtf8Error(#[from] std::string::FromUtf8Error),
20 #[error(transparent)]
21 TryFromIntError(#[from] std::num::TryFromIntError),
22 #[error("Conversion of SQL value from `{1}` to type `{0}` is invalid")]
23 InvalidTypeForFrom(String, String),
24 #[error("Conversion of SQL value to type `{0}` is invalid")]
25 InvalidTypeFor(String),
26 #[error("The maximum number of parameter - `{0}` - has been exceeded. Requested: `{1}`")]
27 MaximumNumberOfParametersExceeded(usize, usize),
28 #[error("Row item `{0}` not found")]
29 RowItemNotFound(usize),
30 #[error("Object insertion failed")]
31 InsertionFail,
32 #[error("Unable to convert result to type `{0}`")]
33 ResultConversionFail(String),
34 #[error("Query returned no result")]
35 QueryReturnNoResult,
36 #[error("No MySql connection provided to Log proxy")]
37 MySqlProxyNoConnectionProvided,
38 #[error("No SQLite connection provided to Log proxy")]
39 SqliteProxyNoConnectionProvided,
40 #[cfg(feature = "mysql")]
41 #[error(transparent)]
42 MysqlFromValueError(#[from] mysql::FromValueError),
43 #[cfg(feature = "mysql")]
44 #[error(transparent)]
45 MysqlError(#[from] mysql::Error),
46 #[cfg(feature = "sqlite")]
47 #[error(transparent)]
48 RusqliteError(#[from] rusqlite::Error),
49 #[cfg(feature = "postgres")]
50 #[error(transparent)]
51 PostgresError(#[from] ::postgres::Error),
52 #[error("Error: {0}")]
53 Misc(String),
54}
55
56impl std::convert::From<&str> for Error {
57 fn from(v: &str) -> Self {
58 Error::Misc(v.to_string())
59 }
60}