// I can probably do this way easier using an external crate, I should do that use rocket::http::Status; /// Represents any general error that the API can encounter during execution. /// It allows us to more easily process errors, and hopefully allows for /// more clear error messages. #[derive(Debug, PartialEq)] pub enum FejError { InvalidArgument, FailedRequest, DatabaseError, } // I'd love to move this over to the server binary, but right now, error E0117 is making that // imopssible impl From for Status { fn from(err: FejError) -> Status { match err { FejError::InvalidArgument => Status::BadRequest, FejError::FailedRequest => Status::InternalServerError, FejError::DatabaseError => Status::InternalServerError, } } } // TODO make this more advanced where possible impl From for FejError { fn from(_: reqwest::Error) -> FejError { FejError::FailedRequest } } impl From for FejError { fn from(_: chrono::ParseError) -> FejError { FejError::InvalidArgument } } impl From for FejError { fn from(_: diesel::result::Error) -> FejError { FejError::DatabaseError } }