polkadot_node_subsystem_types/
errors.rs1use ::orchestra::OrchestraError as OverseerError;
20use fatality::fatality;
21
22#[derive(thiserror::Error, Debug, Clone)]
24pub enum RuntimeApiError {
25 #[error("The runtime API '{runtime_api_name}' cannot be executed: {source}")]
27 Execution {
28 runtime_api_name: &'static str,
30 #[source]
32 source: std::sync::Arc<dyn 'static + std::error::Error + Send + Sync>,
33 },
34
35 #[error("The API is not supported by the runtime at the relay-parent")]
38 NotSupported {
39 runtime_api_name: &'static str,
41 },
42}
43
44#[derive(Debug, Clone)]
46pub struct ChainApiError {
47 msg: String,
48}
49
50impl From<&str> for ChainApiError {
51 fn from(s: &str) -> Self {
52 s.to_owned().into()
53 }
54}
55
56impl From<String> for ChainApiError {
57 fn from(msg: String) -> Self {
58 Self { msg }
59 }
60}
61
62impl core::fmt::Display for ChainApiError {
63 fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
64 write!(f, "{}", self.msg)
65 }
66}
67
68impl std::error::Error for ChainApiError {}
69
70#[derive(PartialEq, Clone)]
72#[fatality(splitable)]
73#[allow(missing_docs)]
74pub enum RecoveryError {
75 #[error("Invalid data")]
76 Invalid,
77
78 #[error("Data is unavailable")]
79 Unavailable,
80
81 #[fatal]
82 #[error("Erasure task channel closed")]
83 ChannelClosed,
84}
85
86#[derive(thiserror::Error, Debug)]
94#[allow(missing_docs)]
95pub enum SubsystemError {
96 #[error(transparent)]
97 NotifyCancellation(#[from] futures::channel::oneshot::Canceled),
98
99 #[error(transparent)]
100 QueueError(#[from] futures::channel::mpsc::SendError),
101
102 #[error(transparent)]
103 Io(#[from] std::io::Error),
104
105 #[error(transparent)]
106 Infallible(#[from] std::convert::Infallible),
107
108 #[error(transparent)]
109 Prometheus(#[from] prometheus_endpoint::PrometheusError),
110
111 #[error("Failed to {0}")]
112 Context(String),
113
114 #[error("Subsystem stalled: {0}")]
115 SubsystemStalled(&'static str),
116
117 #[error(transparent)]
119 Generated(#[from] OverseerError),
120
121 #[error("Error originated in {origin}")]
123 FromOrigin {
124 origin: &'static str,
126 #[source]
128 source: Box<dyn 'static + std::error::Error + Send + Sync>,
129 },
130}
131
132impl SubsystemError {
142 pub fn with_origin<E: 'static + Send + Sync + std::error::Error>(
144 origin: &'static str,
145 err: E,
146 ) -> Self {
147 Self::FromOrigin { origin, source: Box::new(err) }
148 }
149}
150
151pub type SubsystemResult<T> = Result<T, self::SubsystemError>;