Remove IncRefError, DecRefError and StoredMapError (#9384)

All of them are a subset of `DispatchError` anyway, no need to have
special errors IMHO.
This commit is contained in:
Bastian Köcher
2021-07-20 10:39:26 +02:00
committed by GitHub
parent 6d9e05cb9a
commit 2b282a9435
9 changed files with 45 additions and 98 deletions
@@ -29,7 +29,7 @@ impl<T: Config<I>, I: 'static> StoredMap<(T::AssetId, T::AccountId), T::Extra> f
}
}
fn try_mutate_exists<R, E: From<StoredMapError>>(
fn try_mutate_exists<R, E: From<DispatchError>>(
id_who: &(T::AssetId, T::AccountId),
f: impl FnOnce(&mut Option<T::Extra>) -> Result<R, E>,
) -> Result<R, E> {
@@ -46,11 +46,11 @@ impl<T: Config<I>, I: 'static> StoredMap<(T::AssetId, T::AccountId), T::Extra> f
if let Some(ref mut account) = maybe_account {
account.extra = extra;
} else {
Err(StoredMapError::NoProviders)?;
Err(DispatchError::NoProviders)?;
}
} else {
// They want to delete it. Let this pass if the item never existed anyway.
ensure!(maybe_account.is_none(), StoredMapError::ConsumerRemaining);
ensure!(maybe_account.is_none(), DispatchError::ConsumerRemaining);
}
Ok(r)
})
+1 -4
View File
@@ -141,10 +141,7 @@ pub use types::*;
use sp_std::{prelude::*, borrow::Borrow, convert::TryInto};
use sp_runtime::{
TokenError, ArithmeticError,
traits::{
AtLeast32BitUnsigned, Zero, StaticLookup, Saturating, CheckedSub, CheckedAdd, Bounded,
StoredMapError,
}
traits::{AtLeast32BitUnsigned, Zero, StaticLookup, Saturating, CheckedSub, CheckedAdd, Bounded}
};
use codec::HasCompact;
use frame_support::{ensure, dispatch::{DispatchError, DispatchResult}};