polkadot_node_core_provisioner/
error.rs1use fatality::Nested;
19use futures::channel::{mpsc, oneshot};
20use polkadot_node_subsystem::errors::{ChainApiError, RuntimeApiError, SubsystemError};
21use polkadot_node_subsystem_util as util;
22use polkadot_primitives::Hash;
23
24pub type FatalResult<T> = std::result::Result<T, FatalError>;
25pub type Result<T> = std::result::Result<T, Error>;
26
27#[allow(missing_docs)]
29#[fatality::fatality(splitable)]
30pub enum Error {
31 #[fatal(forward)]
32 #[error("Error while accessing runtime information")]
33 Runtime(#[from] util::runtime::Error),
34
35 #[error(transparent)]
36 Util(#[from] util::Error),
37
38 #[error("failed to get availability cores")]
39 CanceledAvailabilityCores(#[source] oneshot::Canceled),
40
41 #[error("failed to get persisted validation data")]
42 CanceledPersistedValidationData(#[source] oneshot::Canceled),
43
44 #[error("failed to get block number")]
45 CanceledBlockNumber(#[source] oneshot::Canceled),
46
47 #[error("failed to get session index")]
48 CanceledSessionIndex(#[source] oneshot::Canceled),
49
50 #[error("failed to get node features")]
51 CanceledNodeFeatures(#[source] oneshot::Canceled),
52
53 #[error("failed to get backed candidates")]
54 CanceledBackedCandidates(#[source] oneshot::Canceled),
55
56 #[error("failed to get votes on dispute")]
57 CanceledCandidateVotes(#[source] oneshot::Canceled),
58
59 #[error("failed to get backable candidates from prospective parachains")]
60 CanceledBackableCandidates(#[source] oneshot::Canceled),
61
62 #[error(transparent)]
63 ChainApi(#[from] ChainApiError),
64
65 #[error(transparent)]
66 RuntimeApi(#[from] RuntimeApiError),
67
68 #[error("failed to send message to ChainAPI")]
69 ChainApiMessageSend(#[source] mpsc::SendError),
70
71 #[error("failed to send message to CandidateBacking to get backed candidates")]
72 GetBackedCandidatesSend(#[source] mpsc::SendError),
73
74 #[error("Send inherent data timeout.")]
75 SendInherentDataTimeout,
76
77 #[error("failed to send return message with Inherents")]
78 InherentDataReturnChannel,
79
80 #[fatal]
81 #[error("Failed to spawn background task")]
82 FailedToSpawnBackgroundTask,
83
84 #[error(transparent)]
85 SubsystemError(#[from] SubsystemError),
86
87 #[fatal]
88 #[error(transparent)]
89 OverseerExited(SubsystemError),
90}
91
92#[allow(dead_code)] #[fatality::fatality]
96pub enum GetOnchainDisputesError {
97 #[fatal]
98 #[error("runtime subsystem is down")]
99 Channel,
100
101 #[error("runtime execution error occurred while fetching onchain disputes for parent {1}")]
102 Execution(#[source] RuntimeApiError, Hash),
103
104 #[error("runtime doesn't support RuntimeApiRequest::Disputes for parent {1}")]
105 NotSupported(#[source] RuntimeApiError, Hash),
106}
107
108pub fn log_error(result: Result<()>) -> std::result::Result<(), FatalError> {
109 match result.into_nested()? {
110 Ok(()) => Ok(()),
111 Err(jfyi) => {
112 jfyi.log();
113 Ok(())
114 },
115 }
116}
117
118impl JfyiError {
119 pub fn log(self) {
121 gum::debug!(target: super::LOG_TARGET, error = ?self);
122 }
123}