Refactor more stuff
This commit is contained in:
parent
5a7b2de0ea
commit
9394a1ae52
15 changed files with 167 additions and 86 deletions
emgauwa-lib/src/errors
|
@ -3,14 +3,12 @@ use actix_web::http::StatusCode;
|
|||
#[derive(Debug)]
|
||||
pub enum ApiError {
|
||||
ProtectedSchedule,
|
||||
InternalError(String),
|
||||
}
|
||||
|
||||
impl ApiError {
|
||||
pub fn get_code(&self) -> StatusCode {
|
||||
match self {
|
||||
ApiError::ProtectedSchedule => StatusCode::FORBIDDEN,
|
||||
ApiError::InternalError(_) => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +17,6 @@ impl From<&ApiError> for String {
|
|||
fn from(err: &ApiError) -> Self {
|
||||
match err {
|
||||
ApiError::ProtectedSchedule => String::from("the targeted schedule is protected"),
|
||||
ApiError::InternalError(msg) => msg.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue