| 15 | /// An error from unsuccessful database operations |
| 16 | #[derive(Error, Debug)] |
| 17 | pub enum DbErr { |
| 18 | /// This error can happen when the connection pool is fully-utilized |
| 19 | #[error("Failed to acquire connection from pool: {0}")] |
| 20 | ConnectionAcquire(#[source] ConnAcquireErr), |
| 21 | /// Runtime type conversion error |
| 22 | #[error("Error converting `{from}` into `{into}`: {source}")] |
| 23 | TryIntoErr { |
| 24 | /// From type |
| 25 | from: &'static str, |
| 26 | /// Into type |
| 27 | into: &'static str, |
| 28 | /// TryError |
| 29 | source: Box<dyn std::error::Error + Send + Sync>, |
| 30 | }, |
| 31 | /// There was a problem with the database connection |
| 32 | #[error("Connection Error: {0}")] |
| 33 | Conn(#[source] RuntimeErr), |
| 34 | /// An operation did not execute successfully |
| 35 | #[error("Execution Error: {0}")] |
| 36 | Exec(#[source] RuntimeErr), |
| 37 | /// An error occurred while performing a query |
| 38 | #[error("Query Error: {0}")] |
| 39 | Query(#[source] RuntimeErr), |
| 40 | /// Type error: the specified type cannot be converted from u64. This is not a runtime error. |
| 41 | #[error("Type '{0}' cannot be converted from u64")] |
| 42 | ConvertFromU64(&'static str), |
| 43 | /// After an insert statement it was impossible to retrieve the last_insert_id |
| 44 | #[error("Failed to unpack last_insert_id")] |
| 45 | UnpackInsertId, |
| 46 | /// When updating, a model should know its primary key to check |
| 47 | /// if the record has been correctly updated, otherwise this error will occur |
| 48 | #[error("Failed to get primary key from model")] |
| 49 | UpdateGetPrimaryKey, |
| 50 | /// The record was not found in the database |
| 51 | #[error("RecordNotFound Error: {0}")] |
| 52 | RecordNotFound(String), |
| 53 | /// Thrown by `TryFrom<ActiveModel>`, which assumes all attributes are set/unchanged |
| 54 | #[error("Attribute {0} is NotSet")] |
| 55 | AttrNotSet(String), |
| 56 | /// A custom error |
| 57 | #[error("Custom Error: {0}")] |
| 58 | Custom(String), |
| 59 | /// Error occurred while parsing value as target type |
| 60 | #[error("Type Error: {0}")] |
| 61 | Type(String), |
| 62 | /// Error occurred while parsing json value as target type |
| 63 | #[error("Json Error: {0}")] |
| 64 | Json(String), |
| 65 | /// A migration error |
| 66 | #[error("Migration Error: {0}")] |
| 67 | Migration(String), |
| 68 | /// None of the records are inserted, |
| 69 | /// that probably means all of them conflict with existing records in the table |
| 70 | #[error("None of the records are inserted")] |
| 71 | RecordNotInserted, |
| 72 | /// None of the records are updated, that means a WHERE condition has no matches. |
| 73 | /// May be the table is empty or the record does not exist |
| 74 | #[error("None of the records are updated")] |
no outgoing calls
no test coverage detected