mirror of https://github.com/fafhrd91/actix-web
added some error logging for extractors
This commit is contained in:
parent
046b7a1425
commit
96baadde7a
|
@ -96,6 +96,7 @@ impl<T: 'static, P> FromRequest<P> for Data<T> {
|
||||||
if let Some(st) = req.app_config().extensions().get::<Data<T>>() {
|
if let Some(st) = req.app_config().extensions().get::<Data<T>>() {
|
||||||
Ok(st.clone())
|
Ok(st.clone())
|
||||||
} else {
|
} else {
|
||||||
|
log::error!("Failed to construct App-level Data extractor");
|
||||||
Err(ErrorInternalServerError(
|
Err(ErrorInternalServerError(
|
||||||
"App data is not configured, to configure use App::data()",
|
"App data is not configured, to configure use App::data()",
|
||||||
))
|
))
|
||||||
|
@ -235,6 +236,7 @@ impl<T: 'static, P> FromRequest<P> for RouteData<T> {
|
||||||
if let Some(st) = req.route_data::<T>() {
|
if let Some(st) = req.route_data::<T>() {
|
||||||
Ok(st.clone())
|
Ok(st.clone())
|
||||||
} else {
|
} else {
|
||||||
|
log::error!("Failed to construct Route-level Data extractor");
|
||||||
Err(ErrorInternalServerError(
|
Err(ErrorInternalServerError(
|
||||||
"Route data is not configured, to configure use Route::data()",
|
"Route data is not configured, to configure use Route::data()",
|
||||||
))
|
))
|
||||||
|
|
|
@ -183,6 +183,7 @@ where
|
||||||
JsonBody::new(req, payload)
|
JsonBody::new(req, payload)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.map_err(move |e| {
|
.map_err(move |e| {
|
||||||
|
log::error!("Failed to deserialize Json from payload");
|
||||||
if let Some(err) = err {
|
if let Some(err) = err {
|
||||||
(*err)(e, &req2)
|
(*err)(e, &req2)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -162,7 +162,10 @@ where
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from_request(req: &HttpRequest, _: &mut Payload<P>) -> Self::Future {
|
fn from_request(req: &HttpRequest, _: &mut Payload<P>) -> Self::Future {
|
||||||
de::Deserialize::deserialize(PathDeserializer::new(req.match_info()))
|
de::Deserialize::deserialize(PathDeserializer::new(req.match_info()))
|
||||||
.map(|inner| Path { inner })
|
.map(|inner| {
|
||||||
|
log::error!("Failed to deserialize during Path extractor");
|
||||||
|
Path { inner }
|
||||||
|
})
|
||||||
.map_err(ErrorNotFound)
|
.map_err(ErrorNotFound)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,6 +122,9 @@ where
|
||||||
fn from_request(req: &HttpRequest, _: &mut Payload<P>) -> Self::Future {
|
fn from_request(req: &HttpRequest, _: &mut Payload<P>) -> Self::Future {
|
||||||
serde_urlencoded::from_str::<T>(req.query_string())
|
serde_urlencoded::from_str::<T>(req.query_string())
|
||||||
.map(|val| Ok(Query(val)))
|
.map(|val| Ok(Query(val)))
|
||||||
.unwrap_or_else(|e| Err(e.into()))
|
.unwrap_or_else(|e| {
|
||||||
|
log::error!("Failed during Query extractor deserialization");
|
||||||
|
Err(e.into())
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue