Database access refactor (#190)

This commit is contained in:
Gregory Schier
2025-03-25 08:35:10 -07:00
committed by GitHub
parent 445c30f3a9
commit 1d37d46130
72 changed files with 4895 additions and 4702 deletions
+20 -1
View File
@@ -1,3 +1,4 @@
use serde::{Serialize, Serializer};
use thiserror::Error;
#[derive(Error, Debug)]
@@ -11,11 +12,29 @@ pub enum Error {
#[error("JSON error: {0}")]
JsonError(#[from] serde_json::Error),
#[error("Model not found {0}")]
#[error("Model not found: {0}")]
ModelNotFound(String),
#[error("Model serialization error: {0}")]
ModelSerializationError(String),
#[error("Model error: {0}")]
GenericError(String),
#[error("Row not found")]
RowNotFound,
#[error("unknown error")]
Unknown,
}
impl Serialize for Error {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_str(self.to_string().as_ref())
}
}
pub type Result<T> = std::result::Result<T, Error>;