Add Diesel error variant
All checks were successful
Push Workflows / rustfmt (push) Successful in 5s
Push Workflows / tailwind-build (push) Successful in 5s
Push Workflows / test (push) Successful in 17s
Push Workflows / docs (push) Successful in 18s
Push Workflows / clippy (push) Successful in 20s
Push Workflows / build (push) Successful in 52s
Push Workflows / nix-build (push) Successful in 4m50s
All checks were successful
Push Workflows / rustfmt (push) Successful in 5s
Push Workflows / tailwind-build (push) Successful in 5s
Push Workflows / test (push) Successful in 17s
Push Workflows / docs (push) Successful in 18s
Push Workflows / clippy (push) Successful in 20s
Push Workflows / build (push) Successful in 52s
Push Workflows / nix-build (push) Successful in 4m50s
This commit is contained in:
@@ -249,6 +249,11 @@ impl<E: Into<Error>> Contextualize<Error> for E {
|
|||||||
|
|
||||||
#[derive(Debug, Clone, thiserror::Error, Deserialize, Serialize)]
|
#[derive(Debug, Clone, thiserror::Error, Deserialize, Serialize)]
|
||||||
pub enum ErrorType {
|
pub enum ErrorType {
|
||||||
|
// Using string to represent Diesel errors, because Diesel's Error type is not `Serialize`,
|
||||||
|
// and Diesel is only available on the server
|
||||||
|
#[error("Database error: {0}")]
|
||||||
|
Database(String),
|
||||||
|
|
||||||
#[error("{0}")]
|
#[error("{0}")]
|
||||||
Error(String),
|
Error(String),
|
||||||
}
|
}
|
||||||
@@ -259,3 +264,11 @@ impl From<ErrorType> for Error {
|
|||||||
Error::new_here(err)
|
Error::new_here(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "server")]
|
||||||
|
impl From<diesel::result::Error> for Error {
|
||||||
|
#[track_caller]
|
||||||
|
fn from(err: diesel::result::Error) -> Self {
|
||||||
|
Error::new_here(ErrorType::Database(format!("{err}")))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user