22 lines
410 B
Rust
22 lines
410 B
Rust
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"),
|
|
}
|
|
}
|
|
}
|