Try state: log errors instead of loggin the number of error and discarding them (#4265)

Currently we discard errors content
We should at least log it.

Code now is more similar to what is written in try_on_runtime_upgrade.

label should be R0

---------

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Liam Aharon <liam.aharon@hotmail.com>
Co-authored-by: Javier Bullrich <javier@bullrich.dev>
This commit is contained in:
gui
2024-04-26 21:27:14 +09:00
committed by GitHub
parent 9a48cd707e
commit 97f7425338
@@ -161,22 +161,31 @@ impl<BlockNumber: Clone + sp_std::fmt::Debug + AtLeast32BitUnsigned> TryState<Bl
match targets {
Select::None => Ok(()),
Select::All => {
let mut error_count = 0;
let mut errors = Vec::<TryRuntimeError>::new();
for_tuples!(#(
if let Err(_) = Tuple::try_state(n.clone(), targets.clone()) {
error_count += 1;
if let Err(err) = Tuple::try_state(n.clone(), targets.clone()) {
errors.push(err);
}
)*);
if error_count > 0 {
if !errors.is_empty() {
log::error!(
target: "try-runtime",
"{} pallets exited with errors while executing try_state checks.",
error_count
"Detected errors while executing `try_state`:",
);
errors.iter().for_each(|err| {
log::error!(
target: "try-runtime",
"{:?}",
err
);
});
return Err(
"Detected errors while executing try_state checks. See logs for more info."
"Detected errors while executing `try_state` checks. See logs for more \
info."
.into(),
)
}