코드 3-10 에러 처리에 에러 사례 추가하기
use warp::{Filter, reject::Reject, Rejection, Reply, http::StatusCode};
...
async fn return_error(r: Rejection) -> Result<impl Reply, Rejection> {
if let Some(_InvalidId) = r.find::<InvalidId>() {
Ok(warp::reply::with_status(
"No valid ID presented",
StatusCode::UNPROCESSABLE_ENTITY,
))
} else {
Ok(warp::reply::with_status(
"Route not found",
StatusCode::NOT_FOUND,
))
}
}
...