Skip to content

Commit

Permalink
Try state: log errors instead of loggin the number of error and disca…
Browse files Browse the repository at this point in the history
…rding 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 <[email protected]>
Co-authored-by: Liam Aharon <[email protected]>
Co-authored-by: Javier Bullrich <[email protected]>
  • Loading branch information
4 people authored Apr 26, 2024
1 parent 9a48cd7 commit 97f7425
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions substrate/frame/support/src/traits/try_runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)
}
Expand Down

0 comments on commit 97f7425

Please sign in to comment.