Introduce ModuleError struct (#10776)

* better partial eq impl

* introduce module error

* fmt

* import module error

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* fixes

* fmt

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Shawn Tabrizi
2022-02-03 14:02:45 +01:00
committed by GitHub
parent 99fae0cd57
commit 21d0cf0eea
9 changed files with 84 additions and 77 deletions
@@ -25,7 +25,7 @@ use sp_io::{
hashing::{blake2_128, twox_128, twox_64},
TestExternalities,
};
use sp_runtime::DispatchError;
use sp_runtime::{DispatchError, ModuleError};
#[frame_support::pallet]
pub mod pallet {
@@ -341,7 +341,11 @@ fn error_expand() {
);
assert_eq!(
DispatchError::from(pallet::Error::<Runtime>::InsufficientProposersBalance),
DispatchError::Module { index: 1, error: 0, message: Some("InsufficientProposersBalance") },
DispatchError::Module(ModuleError {
index: 1,
error: 0,
message: Some("InsufficientProposersBalance")
}),
);
assert_eq!(
@@ -358,7 +362,11 @@ fn error_expand() {
DispatchError::from(
pallet::Error::<Runtime, pallet::Instance1>::InsufficientProposersBalance
),
DispatchError::Module { index: 2, error: 0, message: Some("InsufficientProposersBalance") },
DispatchError::Module(ModuleError {
index: 2,
error: 0,
message: Some("InsufficientProposersBalance")
}),
);
}