Add error type for key-value store
This commit is contained in:
@@ -292,6 +292,11 @@ pub enum ErrorType {
|
|||||||
|
|
||||||
#[error("Server function error: {0}")]
|
#[error("Server function error: {0}")]
|
||||||
ServerFnError(ServerFnError),
|
ServerFnError(ServerFnError),
|
||||||
|
|
||||||
|
// Using string to represent Fred errors, because Fred's Error type is not `Serialize`,
|
||||||
|
// and Fred is only available on the server
|
||||||
|
#[error("Key-value store error: {0}")]
|
||||||
|
KeyValStore(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ErrorType> for Error {
|
impl From<ErrorType> for Error {
|
||||||
@@ -308,3 +313,11 @@ impl From<diesel::result::Error> for Error {
|
|||||||
Error::new_here(ErrorType::Database(format!("{err}")))
|
Error::new_here(ErrorType::Database(format!("{err}")))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "server")]
|
||||||
|
impl From<fred::error::Error> for Error {
|
||||||
|
#[track_caller]
|
||||||
|
fn from(err: fred::error::Error) -> Self {
|
||||||
|
Error::new_here(ErrorType::KeyValStore(format!("{err}")))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user