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

Commit

Permalink
add sub errors to SubSystemError
Browse files Browse the repository at this point in the history
  • Loading branch information
drahnr committed Oct 21, 2020
1 parent 8ad2f36 commit 11b1664
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
9 changes: 5 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node/subsystem/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ polkadot-statement-table = { path = "../../statement-table" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
smallvec = "1.4.1"
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
thiserror = "1.0.21"

[dev-dependencies]
assert_matches = "1.3.0"
Expand Down
19 changes: 15 additions & 4 deletions node/subsystem/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,30 @@ pub enum FromOverseer<M> {
},
}


use thiserror::Error;
/// An error type that describes faults that may happen
///
/// These are:
/// * Channels being closed
/// * Subsystems dying when they are not expected to
/// * Subsystems not dying when they are told to die
/// * etc.
#[derive(Debug, PartialEq, Eq)]
pub struct SubsystemError;
#[derive(Error, Debug, PartialEq, Eq)]
pub enum SubsystemError {
#[error(transparent)]
NotifyCancellation(#[from] oneshot::Canceled),
#[error(transparent)]
QueueError(#[from] mpsc::SendError),
#[error(transparent)]
TaskSpawn(#[from] futures::task::SpawnError),
#[error(transparent)]
Infallible(#[from] std::convert::Infallible),
}

impl From<mpsc::SendError> for SubsystemError {
fn from(_: mpsc::SendError) -> Self {
Self
fn from(error: mpsc::SendError) -> Self {
Self::Queue()
}
}

Expand Down

0 comments on commit 11b1664

Please sign in to comment.