From 6f75b0e95e11c6d34288796433795de3cfdbd617 Mon Sep 17 00:00:00 2001 From: Niklas Fiekas Date: Tue, 8 May 2018 22:45:28 +0200 Subject: [PATCH] let Path::from_request() fail with ErrorNotFound --- CHANGES.md | 2 ++ src/extractor.rs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index a96fd3318..a42cbe6a0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,8 @@ * Fix connector's default `keep-alive` and `lifetime` settings #212 +* Send `ErrorNotFound` instead of `ErrorBadRequest` when path extractor fails #214 + ## 0.6.0 (2018-05-08) * Add route scopes #202 diff --git a/src/extractor.rs b/src/extractor.rs index 1f06f782d..a08e96674 100644 --- a/src/extractor.rs +++ b/src/extractor.rs @@ -11,7 +11,7 @@ use serde::de::{self, DeserializeOwned}; use serde_urlencoded; use de::PathDeserializer; -use error::{Error, ErrorBadRequest}; +use error::{Error, ErrorNotFound, ErrorBadRequest}; use handler::{AsyncResult, FromRequest}; use httpmessage::{HttpMessage, MessageBody, UrlEncoded}; use httprequest::HttpRequest; @@ -108,7 +108,7 @@ where fn from_request(req: &HttpRequest, _: &Self::Config) -> Self::Result { let req = req.clone(); de::Deserialize::deserialize(PathDeserializer::new(&req)) - .map_err(|e| e.into()) + .map_err(ErrorNotFound) .map(|inner| Path { inner }) } }