mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-29 12:37:25 +00:00
pvf-precheck: teach runtime-api to work with versions (#4510)
As part of #3211 we will need to add a couple of runtime APIs. That change is coming in a following PR. The runtime API for pre-checking will be introduced with a version bump for `ParachainHost`. This commit prepares the ground for that change, by introducing a error condition that signals that the given API is not supported.
This commit is contained in:
@@ -19,23 +19,27 @@
|
||||
use crate::JaegerError;
|
||||
|
||||
/// A description of an error causing the runtime API request to be unservable.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct RuntimeApiError(String);
|
||||
#[derive(thiserror::Error, Debug, Clone)]
|
||||
pub enum RuntimeApiError {
|
||||
/// The runtime API cannot be executed due to a
|
||||
#[error("The runtime API '{runtime_api_name}' cannot be executed")]
|
||||
Execution {
|
||||
/// The runtime API being called
|
||||
runtime_api_name: &'static str,
|
||||
/// The wrapped error. Marked as source for tracking the error chain.
|
||||
#[source]
|
||||
source: std::sync::Arc<dyn 'static + std::error::Error + Send + Sync>,
|
||||
},
|
||||
|
||||
impl From<String> for RuntimeApiError {
|
||||
fn from(s: String) -> Self {
|
||||
RuntimeApiError(s)
|
||||
}
|
||||
/// The runtime API request in question cannot be executed because the runtime at the requested
|
||||
/// relay-parent is an old version.
|
||||
#[error("The API is not supported by the runtime at the relay-parent")]
|
||||
NotSupported {
|
||||
/// The runtime API being called
|
||||
runtime_api_name: &'static str,
|
||||
},
|
||||
}
|
||||
|
||||
impl core::fmt::Display for RuntimeApiError {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
|
||||
write!(f, "{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for RuntimeApiError {}
|
||||
|
||||
/// A description of an error causing the chain API request to be unservable.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ChainApiError {
|
||||
|
||||
Reference in New Issue
Block a user