Improve guard forward and failure logs.

This commit is contained in:
Sergio Benitez 2021-06-10 01:25:49 -07:00
parent c2960e7e6f
commit e45e164561
1 changed files with 6 additions and 6 deletions

View File

@ -100,7 +100,7 @@ fn query_decls(route: &Route) -> Option<TokenStream> {
)*
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); }
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 {
#Outcome::Success(__v) => __v,
#Outcome::Forward(_) => {
#_log::warn_!("`{}` request guard is forwarding.", stringify!(#ty));
#_log::warn_!("Request guard `{}` is forwarding.", stringify!(#ty));
return #Outcome::Forward(#__data);
},
#Outcome::Failure((__c, __e)) => {
#_log::warn_!("`{}` request guard failed: {:?}.", stringify!(#ty), __e);
#_log::warn_!("Request guard `{}` failed: {:?}.", stringify!(#ty), __e);
return #Outcome::Failure(__c);
}
};
@ -139,7 +139,7 @@ fn param_guard_decl(guard: &Guard) -> TokenStream {
// Returned when a dynamic parameter fails to parse.
let parse_error = quote!({
#_log::warn_!("`{}: {}` param guard parsed forwarding with error {:?}",
#_log::warn_!("Parameter guard `{}: {}` is forwarding: {:?}.",
#name, stringify!(#ty), __error);
#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 {
#Outcome::Success(__d) => __d,
#Outcome::Forward(__d) => {
#_log::warn_!("`{}` data guard is forwarding.", stringify!(#ty));
#_log::warn_!("Data guard `{}` is forwarding.", stringify!(#ty));
return #Outcome::Forward(__d);
}
#Outcome::Failure((__c, __e)) => {
#_log::warn_!("`{}` data guard failed: {:?}.", stringify!(#ty), __e);
#_log::warn_!("Data guard `{}` failed: {:?}.", stringify!(#ty), __e);
return #Outcome::Failure(__c);
}
};