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