2021-04-08 10:11:15 +02:00
|
|
|
// 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;
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
2021-04-08 10:11:15 +02:00
|
|
|
|
|
|
|
impl From<chrono::ParseError> for FejError {
|
|
|
|
fn from(_: chrono::ParseError) -> FejError {
|
|
|
|
FejError::InvalidArgument
|
|
|
|
}
|
|
|
|
}
|