polkadot_node_core_prospective_parachains/
error.rs1use futures::channel::oneshot;
20
21use polkadot_node_subsystem::{
22 errors::{ChainApiError, RuntimeApiError},
23 SubsystemError,
24};
25use polkadot_node_subsystem_util::runtime;
26
27use crate::LOG_TARGET;
28use fatality::Nested;
29
30#[allow(missing_docs)]
31#[fatality::fatality(splitable)]
32pub enum Error {
33 #[fatal]
34 #[error("Receiving message from overseer failed: {0}")]
35 SubsystemReceive(#[source] SubsystemError),
36
37 #[error("Error while accessing runtime information")]
38 Runtime(#[from] runtime::Error),
39
40 #[error(transparent)]
41 RuntimeApi(#[from] RuntimeApiError),
42
43 #[error(transparent)]
44 ChainApi(#[from] ChainApiError),
45
46 #[error("Request to chain API subsystem dropped")]
47 ChainApiRequestCanceled(oneshot::Canceled),
48
49 #[error("Request to runtime API subsystem dropped")]
50 RuntimeApiRequestCanceled(oneshot::Canceled),
51}
52
53pub type Result<R> = std::result::Result<R, Error>;
55pub type JfyiErrorResult<T> = std::result::Result<T, JfyiError>;
57pub type FatalResult<T> = std::result::Result<T, FatalError>;
59
60pub fn log_error(result: Result<()>, ctx: &'static str) -> FatalResult<()> {
65 match result.into_nested()? {
66 Ok(()) => Ok(()),
67 Err(jfyi) => {
68 gum::debug!(target: LOG_TARGET, error = ?jfyi, ctx);
69 Ok(())
70 },
71 }
72}