fej/src/errors.rs

31 lines
747 B
Rust
Raw Normal View History

// I can probably do this way easier using an external crate, I should do that
2021-04-04 13:03:08 +02:00
use rocket::http::Status;
#[derive(Debug, PartialEq)]
2021-04-04 13:03:08 +02:00
pub enum FejError {
InvalidArgument,
FailedRequest,
}
impl From<FejError> for Status {
fn from(err: FejError) -> Status {
match err {
FejError::InvalidArgument => Status::BadRequest,
FejError::FailedRequest => Status::InternalServerError,
}
}
}
// TODO make this more advanced where possible
2021-04-05 11:00:41 +02:00
impl From<reqwest::Error> for FejError {
fn from(_: reqwest::Error) -> FejError {
2021-04-04 13:03:08 +02:00
FejError::FailedRequest
}
}
impl From<chrono::ParseError> for FejError {
fn from(_: chrono::ParseError) -> FejError {
FejError::InvalidArgument
}
}