Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 11b1664

Browse files
committed
add sub errors to SubSystemError
1 parent 8ad2f36 commit 11b1664

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

Cargo.lock

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node/subsystem/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ polkadot-statement-table = { path = "../../statement-table" }
2121
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
2222
smallvec = "1.4.1"
2323
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
24+
thiserror = "1.0.21"
2425

2526
[dev-dependencies]
2627
assert_matches = "1.3.0"

node/subsystem/src/lib.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,30 @@ pub enum FromOverseer<M> {
105105
},
106106
}
107107

108+
109+
use thiserror::Error;
108110
/// An error type that describes faults that may happen
109111
///
110112
/// These are:
111113
/// * Channels being closed
112114
/// * Subsystems dying when they are not expected to
113115
/// * Subsystems not dying when they are told to die
114116
/// * etc.
115-
#[derive(Debug, PartialEq, Eq)]
116-
pub struct SubsystemError;
117+
#[derive(Error, Debug, PartialEq, Eq)]
118+
pub enum SubsystemError {
119+
#[error(transparent)]
120+
NotifyCancellation(#[from] oneshot::Canceled),
121+
#[error(transparent)]
122+
QueueError(#[from] mpsc::SendError),
123+
#[error(transparent)]
124+
TaskSpawn(#[from] futures::task::SpawnError),
125+
#[error(transparent)]
126+
Infallible(#[from] std::convert::Infallible),
127+
}
117128

118129
impl From<mpsc::SendError> for SubsystemError {
119-
fn from(_: mpsc::SendError) -> Self {
120-
Self
130+
fn from(error: mpsc::SendError) -> Self {
131+
Self::Queue()
121132
}
122133
}
123134

0 commit comments

Comments
 (0)