Changed Error messages

This commit is contained in:
Jonas_Jones 2023-12-15 04:46:46 +01:00
parent b675ed4094
commit f0e9ab0d59

View file

@ -25,13 +25,13 @@ pub async fn serve() {
async fn handle_rejection(err: warp::Rejection) -> Result<impl Reply, Infallible> { async fn handle_rejection(err: warp::Rejection) -> Result<impl Reply, Infallible> {
let (code, message) = if err.find::<InternalServerError>().is_some() { let (code, message) = if err.find::<InternalServerError>().is_some() {
(StatusCode::INTERNAL_SERVER_ERROR, "INTERNAL_SERVER_ERROR") (StatusCode::INTERNAL_SERVER_ERROR, "Internal Server Error")
} else if err.find::<BadRequestError>().is_some() { } else if err.find::<BadRequestError>().is_some() {
(StatusCode::BAD_REQUEST, "BAD_REQUEST") (StatusCode::BAD_REQUEST, "Bad Request")
} else if err.is_not_found() || err.find::<NotFoundError>().is_some() { } else if err.is_not_found() || err.find::<NotFoundError>().is_some() {
(StatusCode::NOT_FOUND, "NOT_FOUND") (StatusCode::NOT_FOUND, "Not Found")
} else { } else {
(StatusCode::INTERNAL_SERVER_ERROR, "INTERNAL_SERVER_ERROR") // Default case (StatusCode::INTERNAL_SERVER_ERROR, "Unhandled Rejection") // Default case
}; };
let json = warp::reply::json(&ErrorMessage { let json = warp::reply::json(&ErrorMessage {