Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Log + debug assert when refetching an Id
Browse files Browse the repository at this point in the history
  • Loading branch information
emostov committed Dec 7, 2021
1 parent aa4d896 commit 944dc85
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion frame/bags-list/src/list/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,12 @@ impl<T: Config> List<T> {

// re-fetch `lighter_node` from storage since it may have been updated when `heavier_node`
// was removed.
let lighter_node = Node::<T>::get(&lighter_id).ok_or(pallet::Error::IdNotFound)?;
let lighter_node = Node::<T>::get(&lighter_id).ok_or_else(|| {
debug_assert!(false, "id that should exist cannot be found");
crate::log!(warn, "id that should exist cannot be found");
pallet::Error::IdNotFound
})?;

// insert `heavier_node` directly in front of `lighter_node`. This will update both nodes
// in storage and update the node counter.
Self::insert_at_unchecked(lighter_node, heavier_node);
Expand Down

0 comments on commit 944dc85

Please sign in to comment.