polkadot_node_core_backing/
error.rs1use std::collections::HashMap;
18
19use fatality::Nested;
20use futures::channel::{mpsc, oneshot};
21
22use polkadot_node_subsystem::{
23 messages::{StoreAvailableDataError, ValidationFailed},
24 RuntimeApiError, SubsystemError,
25};
26use polkadot_node_subsystem_util::{runtime, Error as UtilError};
27use polkadot_primitives::{BackedCandidate, ValidationCodeHash};
28
29use crate::{ParaId, LOG_TARGET};
30
31pub type Result<T> = std::result::Result<T, Error>;
32pub type FatalResult<T> = std::result::Result<T, FatalError>;
33
34#[allow(missing_docs)]
36#[fatality::fatality(splitable)]
37pub enum Error {
38 #[fatal]
39 #[error("Failed to spawn background task")]
40 FailedToSpawnBackgroundTask,
41
42 #[fatal(forward)]
43 #[error("Error while accessing runtime information")]
44 Runtime(#[from] runtime::Error),
45
46 #[fatal]
47 #[error(transparent)]
48 BackgroundValidationMpsc(#[from] mpsc::SendError),
49
50 #[error("Candidate is not found")]
51 CandidateNotFound,
52
53 #[error("CoreIndex cannot be determined for a candidate")]
54 CoreIndexUnavailable,
55
56 #[error("Signature is invalid")]
57 InvalidSignature,
58
59 #[error("Failed to send candidates {0:?}")]
60 Send(HashMap<ParaId, Vec<BackedCandidate>>),
61
62 #[error("FetchPoV failed")]
63 FetchPoV,
64
65 #[error("Fetching validation code by hash failed {0:?}, {1:?}")]
66 FetchValidationCode(ValidationCodeHash, RuntimeApiError),
67
68 #[error("Fetching Runtime API version failed {0:?}")]
69 FetchRuntimeApiVersion(RuntimeApiError),
70
71 #[error("No validation code {0:?}")]
72 NoValidationCode(ValidationCodeHash),
73
74 #[error("Candidate rejected by prospective parachains subsystem")]
75 RejectedByProspectiveParachains,
76
77 #[error("ValidateFromExhaustive channel closed before receipt")]
78 ValidateFromExhaustive(#[source] oneshot::Canceled),
79
80 #[error("StoreAvailableData channel closed before receipt")]
81 StoreAvailableDataChannel(#[source] oneshot::Canceled),
82
83 #[error("RuntimeAPISubsystem channel closed before receipt")]
84 RuntimeApiUnavailable(#[source] oneshot::Canceled),
85
86 #[error("a channel was closed before receipt in try_join!")]
87 #[fatal]
88 JoinMultiple(#[source] oneshot::Canceled),
89
90 #[error("Obtaining erasure chunks failed")]
91 ObtainErasureChunks(#[from] polkadot_erasure_coding::Error),
92
93 #[error(transparent)]
94 ValidationFailed(#[from] ValidationFailed),
95
96 #[error(transparent)]
97 UtilError(#[from] UtilError),
98
99 #[error(transparent)]
100 SubsystemError(#[from] SubsystemError),
101
102 #[fatal]
103 #[error(transparent)]
104 OverseerExited(SubsystemError),
105
106 #[error("Availability store error")]
107 StoreAvailableData(#[source] StoreAvailableDataError),
108
109 #[error("Runtime API returned None for executor params")]
110 MissingExecutorParams,
111}
112
113pub fn log_error(result: Result<()>) -> std::result::Result<(), FatalError> {
118 match result.into_nested()? {
119 Ok(()) => Ok(()),
120 Err(jfyi) => {
121 jfyi.log();
122 Ok(())
123 },
124 }
125}
126
127impl JfyiError {
128 pub fn log(self) {
130 gum::debug!(target: LOG_TARGET, error = ?self);
131 }
132}