frame_support::dispatchTrait WithPostDispatchInfo
Source pub trait WithPostDispatchInfo {
// Required method
fn with_weight(self, actual_weight: Weight) -> DispatchErrorWithPostInfo;
}
Expand description
Allows easy conversion from DispatchError
to DispatchErrorWithPostInfo
for dispatchables
that want to return a custom a posterior weight on error.
Call this on your modules custom errors type in order to return a custom weight on error.
§Example
ⓘlet who = ensure_signed(origin).map_err(|e| e.with_weight(Weight::from_parts(100, 0)))?;
ensure!(who == me, Error::<T>::NotMe.with_weight(200_000));