mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 21:37:56 +00:00
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:
@@ -27,7 +27,7 @@ use sp_core::{sr25519, H256};
|
||||
use sp_runtime::{
|
||||
generic,
|
||||
traits::{BlakeTwo256, Verify},
|
||||
DispatchError,
|
||||
DispatchError, ModuleError,
|
||||
};
|
||||
use sp_std::cell::RefCell;
|
||||
|
||||
@@ -363,47 +363,47 @@ mod origin_test {
|
||||
fn check_modules_error_type() {
|
||||
assert_eq!(
|
||||
Module1_1::fail(system::Origin::<Runtime>::Root.into()),
|
||||
Err(DispatchError::Module { index: 31, error: 0, message: Some("Something") }),
|
||||
Err(DispatchError::Module(ModuleError { index: 31, error: 0, message: Some("Something") })),
|
||||
);
|
||||
assert_eq!(
|
||||
Module2::fail(system::Origin::<Runtime>::Root.into()),
|
||||
Err(DispatchError::Module { index: 32, error: 0, message: Some("Something") }),
|
||||
Err(DispatchError::Module(ModuleError { index: 32, error: 0, message: Some("Something") })),
|
||||
);
|
||||
assert_eq!(
|
||||
Module1_2::fail(system::Origin::<Runtime>::Root.into()),
|
||||
Err(DispatchError::Module { index: 33, error: 0, message: Some("Something") }),
|
||||
Err(DispatchError::Module(ModuleError { index: 33, error: 0, message: Some("Something") })),
|
||||
);
|
||||
assert_eq!(
|
||||
NestedModule3::fail(system::Origin::<Runtime>::Root.into()),
|
||||
Err(DispatchError::Module { index: 34, error: 0, message: Some("Something") }),
|
||||
Err(DispatchError::Module(ModuleError { index: 34, error: 0, message: Some("Something") })),
|
||||
);
|
||||
assert_eq!(
|
||||
Module1_3::fail(system::Origin::<Runtime>::Root.into()),
|
||||
Err(DispatchError::Module { index: 6, error: 0, message: Some("Something") }),
|
||||
Err(DispatchError::Module(ModuleError { index: 6, error: 0, message: Some("Something") })),
|
||||
);
|
||||
assert_eq!(
|
||||
Module1_4::fail(system::Origin::<Runtime>::Root.into()),
|
||||
Err(DispatchError::Module { index: 3, error: 0, message: Some("Something") }),
|
||||
Err(DispatchError::Module(ModuleError { index: 3, error: 0, message: Some("Something") })),
|
||||
);
|
||||
assert_eq!(
|
||||
Module1_5::fail(system::Origin::<Runtime>::Root.into()),
|
||||
Err(DispatchError::Module { index: 4, error: 0, message: Some("Something") }),
|
||||
Err(DispatchError::Module(ModuleError { index: 4, error: 0, message: Some("Something") })),
|
||||
);
|
||||
assert_eq!(
|
||||
Module1_6::fail(system::Origin::<Runtime>::Root.into()),
|
||||
Err(DispatchError::Module { index: 1, error: 0, message: Some("Something") }),
|
||||
Err(DispatchError::Module(ModuleError { index: 1, error: 0, message: Some("Something") })),
|
||||
);
|
||||
assert_eq!(
|
||||
Module1_7::fail(system::Origin::<Runtime>::Root.into()),
|
||||
Err(DispatchError::Module { index: 2, error: 0, message: Some("Something") }),
|
||||
Err(DispatchError::Module(ModuleError { index: 2, error: 0, message: Some("Something") })),
|
||||
);
|
||||
assert_eq!(
|
||||
Module1_8::fail(system::Origin::<Runtime>::Root.into()),
|
||||
Err(DispatchError::Module { index: 12, error: 0, message: Some("Something") }),
|
||||
Err(DispatchError::Module(ModuleError { index: 12, error: 0, message: Some("Something") })),
|
||||
);
|
||||
assert_eq!(
|
||||
Module1_9::fail(system::Origin::<Runtime>::Root.into()),
|
||||
Err(DispatchError::Module { index: 13, error: 0, message: Some("Something") }),
|
||||
Err(DispatchError::Module(ModuleError { index: 13, error: 0, message: Some("Something") })),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ use sp_io::{
|
||||
hashing::{blake2_128, twox_128, twox_64},
|
||||
TestExternalities,
|
||||
};
|
||||
use sp_runtime::DispatchError;
|
||||
use sp_runtime::{DispatchError, ModuleError};
|
||||
|
||||
pub struct SomeType1;
|
||||
impl From<SomeType1> for u64 {
|
||||
@@ -654,7 +654,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")
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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")
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user