Simplify runtime api error handling (#8114)

* Ahh

* Work work work

* Fix all the compilation errors

* Fix test

* More fixes...
This commit is contained in:
Bastian Köcher
2021-02-15 12:55:40 +01:00
committed by GitHub
parent b5e692104c
commit 33f9becf41
48 changed files with 270 additions and 415 deletions
@@ -392,7 +392,7 @@ mod execution {
bool,
) where
R: Decode + Encode + PartialEq,
NC: FnOnce() -> result::Result<R, String> + UnwindSafe,
NC: FnOnce() -> result::Result<R, Box<dyn std::error::Error + Send + Sync>> + UnwindSafe,
{
let mut cache = StorageTransactionCache::default();
@@ -449,7 +449,7 @@ mod execution {
) -> CallResult<R, Exec::Error>
where
R: Decode + Encode + PartialEq,
NC: FnOnce() -> result::Result<R, String> + UnwindSafe,
NC: FnOnce() -> result::Result<R, Box<dyn std::error::Error + Send + Sync>> + UnwindSafe,
Handler: FnOnce(
CallResult<R, Exec::Error>,
CallResult<R, Exec::Error>,
@@ -485,7 +485,7 @@ mod execution {
) -> CallResult<R, Exec::Error>
where
R: Decode + Encode + PartialEq,
NC: FnOnce() -> result::Result<R, String> + UnwindSafe,
NC: FnOnce() -> result::Result<R, Box<dyn std::error::Error + Send + Sync>> + UnwindSafe,
{
self.overlay.start_transaction();
let (result, was_native) = self.execute_aux(
@@ -522,7 +522,7 @@ mod execution {
) -> Result<NativeOrEncoded<R>, Box<dyn Error>>
where
R: Decode + Encode + PartialEq,
NC: FnOnce() -> result::Result<R, String> + UnwindSafe,
NC: FnOnce() -> result::Result<R, Box<dyn std::error::Error + Send + Sync>> + UnwindSafe,
Handler: FnOnce(
CallResult<R, Exec::Error>,
CallResult<R, Exec::Error>,
@@ -869,7 +869,7 @@ mod tests {
map, traits::{Externalities, RuntimeCode}, testing::TaskExecutor,
};
use sp_runtime::traits::BlakeTwo256;
use std::{result, collections::HashMap};
use std::{result, collections::HashMap, panic::UnwindSafe};
use codec::Decode;
use sp_core::{
storage::ChildInfo, NativeOrEncoded, NeverNativeValue,
@@ -891,7 +891,7 @@ mod tests {
fn call<
R: Encode + Decode + PartialEq,
NC: FnOnce() -> result::Result<R, String>,
NC: FnOnce() -> result::Result<R, Box<dyn std::error::Error + Send + Sync>> + UnwindSafe,
>(
&self,
ext: &mut dyn Externalities,