Implemented settings for properties of reservation. Fixed bugs on empty database.
This commit is contained in:
+23
-4
@@ -1,15 +1,21 @@
|
||||
use std::error::Error;
|
||||
use std::fmt::{Debug, Display, Formatter};
|
||||
use leptos::ServerFnError;
|
||||
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
pub enum AppError {
|
||||
HourParseError
|
||||
HourParseError,
|
||||
ServerError(String),
|
||||
FatalError(String)
|
||||
}
|
||||
|
||||
impl AppError {
|
||||
fn as_string(&self) -> String {
|
||||
//match self { AppError::HourParseError => {"Hour parse error"} }
|
||||
"Hours parse error".to_string()
|
||||
match self {
|
||||
AppError::HourParseError => {"Hour parse error".to_string()},
|
||||
AppError::ServerError(e) => {format!("Server error: {}", e)},
|
||||
AppError::FatalError(e) => {format!("Fatal error: {}", e)}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,4 +25,17 @@ impl Display for AppError {
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for AppError {}
|
||||
impl Error for AppError {}
|
||||
|
||||
impl From<ServerFnError> for AppError {
|
||||
fn from(value: ServerFnError) -> Self {
|
||||
AppError::ServerError(value.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "ssr")]
|
||||
impl From<sqlx::Error> for AppError {
|
||||
fn from(value: sqlx::Error) -> Self {
|
||||
AppError::FatalError(value.to_string())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user