Rename emgauwa-lib to emgauwa-common
This commit is contained in:
parent
6340cfd5c7
commit
9bc75b9627
58 changed files with 135 additions and 100 deletions
emgauwa-common/src/errors
22
emgauwa-common/src/errors/api_error.rs
Normal file
22
emgauwa-common/src/errors/api_error.rs
Normal 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"),
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue