From 1cf1bfcfbc15d5328414758fd994700a7e1392fb Mon Sep 17 00:00:00 2001 From: Ethan Girouard Date: Sun, 21 Jun 2026 12:28:01 -0400 Subject: [PATCH] Add Diesel error variant --- src/util/error.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/util/error.rs b/src/util/error.rs index c3e5b25..ae9a4bf 100644 --- a/src/util/error.rs +++ b/src/util/error.rs @@ -249,6 +249,11 @@ impl> Contextualize for E { #[derive(Debug, Clone, thiserror::Error, Deserialize, Serialize)] 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(String), } @@ -259,3 +264,11 @@ impl From for Error { Error::new_here(err) } } + +#[cfg(feature = "server")] +impl From for Error { + #[track_caller] + fn from(err: diesel::result::Error) -> Self { + Error::new_here(ErrorType::Database(format!("{err}"))) + } +}