mirror of https://github.com/rwf2/Rocket.git
Improve guard forward and failure logs.
This commit is contained in:
parent
c2960e7e6f
commit
e45e164561
|
@ -100,7 +100,7 @@ fn query_decls(route: &Route) -> Option<TokenStream> {
|
||||||
)*
|
)*
|
||||||
|
|
||||||
if !__e.is_empty() {
|
if !__e.is_empty() {
|
||||||
#_log::warn_!("query string failed to match declared route");
|
#_log::warn_!("Query string failed to match route declaration.");
|
||||||
for _err in __e { #_log::warn_!("{}", _err); }
|
for _err in __e { #_log::warn_!("{}", _err); }
|
||||||
return #Outcome::Forward(#__data);
|
return #Outcome::Forward(#__data);
|
||||||
}
|
}
|
||||||
|
@ -119,11 +119,11 @@ fn request_guard_decl(guard: &Guard) -> TokenStream {
|
||||||
let #ident: #ty = match <#ty as #FromRequest>::from_request(#__req).await {
|
let #ident: #ty = match <#ty as #FromRequest>::from_request(#__req).await {
|
||||||
#Outcome::Success(__v) => __v,
|
#Outcome::Success(__v) => __v,
|
||||||
#Outcome::Forward(_) => {
|
#Outcome::Forward(_) => {
|
||||||
#_log::warn_!("`{}` request guard is forwarding.", stringify!(#ty));
|
#_log::warn_!("Request guard `{}` is forwarding.", stringify!(#ty));
|
||||||
return #Outcome::Forward(#__data);
|
return #Outcome::Forward(#__data);
|
||||||
},
|
},
|
||||||
#Outcome::Failure((__c, __e)) => {
|
#Outcome::Failure((__c, __e)) => {
|
||||||
#_log::warn_!("`{}` request guard failed: {:?}.", stringify!(#ty), __e);
|
#_log::warn_!("Request guard `{}` failed: {:?}.", stringify!(#ty), __e);
|
||||||
return #Outcome::Failure(__c);
|
return #Outcome::Failure(__c);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -139,7 +139,7 @@ fn param_guard_decl(guard: &Guard) -> TokenStream {
|
||||||
|
|
||||||
// Returned when a dynamic parameter fails to parse.
|
// Returned when a dynamic parameter fails to parse.
|
||||||
let parse_error = quote!({
|
let parse_error = quote!({
|
||||||
#_log::warn_!("`{}: {}` param guard parsed forwarding with error {:?}",
|
#_log::warn_!("Parameter guard `{}: {}` is forwarding: {:?}.",
|
||||||
#name, stringify!(#ty), __error);
|
#name, stringify!(#ty), __error);
|
||||||
|
|
||||||
#Outcome::Forward(#__data)
|
#Outcome::Forward(#__data)
|
||||||
|
@ -182,11 +182,11 @@ fn data_guard_decl(guard: &Guard) -> TokenStream {
|
||||||
let #ident: #ty = match <#ty as #FromData>::from_data(#__req, #__data).await {
|
let #ident: #ty = match <#ty as #FromData>::from_data(#__req, #__data).await {
|
||||||
#Outcome::Success(__d) => __d,
|
#Outcome::Success(__d) => __d,
|
||||||
#Outcome::Forward(__d) => {
|
#Outcome::Forward(__d) => {
|
||||||
#_log::warn_!("`{}` data guard is forwarding.", stringify!(#ty));
|
#_log::warn_!("Data guard `{}` is forwarding.", stringify!(#ty));
|
||||||
return #Outcome::Forward(__d);
|
return #Outcome::Forward(__d);
|
||||||
}
|
}
|
||||||
#Outcome::Failure((__c, __e)) => {
|
#Outcome::Failure((__c, __e)) => {
|
||||||
#_log::warn_!("`{}` data guard failed: {:?}.", stringify!(#ty), __e);
|
#_log::warn_!("Data guard `{}` failed: {:?}.", stringify!(#ty), __e);
|
||||||
return #Outcome::Failure(__c);
|
return #Outcome::Failure(__c);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue