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
+11 -3
View File
@@ -114,8 +114,8 @@ pub enum Error {
#[error("Error decoding call result of {0}")]
CallResultDecode(&'static str, #[source] CodecError),
#[error(transparent)]
RuntimeApiCodecError(#[from] ApiError),
#[error("Error at calling runtime api: {0}")]
RuntimeApiError(#[from] ApiError),
#[error("Runtime :code missing in storage")]
RuntimeCodeMissing,
@@ -153,7 +153,6 @@ pub enum Error {
#[error("Failed to get header for hash {0}")]
MissingHeader(String),
#[error("State Database error: {0}")]
StateDatabase(String),
@@ -183,6 +182,15 @@ impl From<Box<dyn sp_state_machine::Error>> for Error {
}
}
impl From<Error> for ApiError {
fn from(err: Error) -> ApiError {
match err {
Error::RuntimeApiError(err) => err,
e => ApiError::Application(Box::new(e)),
}
}
}
impl Error {
/// Chain a blockchain error.
pub fn from_blockchain(e: Box<Error>) -> Self {