Rename emgauwa-lib to emgauwa-common

This commit is contained in:
Tobias Reisinger 2024-04-30 08:44:33 +02:00
parent 6340cfd5c7
commit 9bc75b9627
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
58 changed files with 135 additions and 100 deletions
emgauwa-common/src/errors

View file

@ -0,0 +1,22 @@
use actix_web::http::StatusCode;
#[derive(Debug)]
pub enum ApiError {
ProtectedSchedule,
}
impl ApiError {
pub fn get_code(&self) -> StatusCode {
match self {
ApiError::ProtectedSchedule => StatusCode::FORBIDDEN,
}
}
}
impl From<&ApiError> for String {
fn from(err: &ApiError) -> Self {
match err {
ApiError::ProtectedSchedule => String::from("the targeted schedule is protected"),
}
}
}