mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 09:21:05 +00:00
introduce errors with info (#1834)
This commit is contained in:
committed by
GitHub
parent
40ea09389c
commit
f345123748
@@ -6,19 +6,16 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
futures = "0.3.5"
|
||||
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
polkadot-primitives = { path = "../../../primitives" }
|
||||
polkadot-node-primitives = { path = "../../primitives" }
|
||||
polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsystem" }
|
||||
polkadot-node-subsystem-util = { path = "../../subsystem-util" }
|
||||
erasure-coding = { package = "polkadot-erasure-coding", path = "../../../erasure-coding" }
|
||||
statement-table = { package = "polkadot-statement-table", path = "../../../statement-table" }
|
||||
derive_more = "0.99.9"
|
||||
bitvec = { version = "0.17.4", default-features = false, features = ["alloc"] }
|
||||
log = "0.4.8"
|
||||
log = "0.4.11"
|
||||
thiserror = "1.0.21"
|
||||
|
||||
[dev-dependencies]
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
//! Implements a `CandidateBackingSubsystem`.
|
||||
|
||||
#![deny(unused_crate_dependencies)]
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::convert::TryFrom;
|
||||
use std::pin::Pin;
|
||||
@@ -64,22 +66,26 @@ use statement_table::{
|
||||
SignedStatement as TableSignedStatement, Summary as TableSummary,
|
||||
},
|
||||
};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, derive_more::From)]
|
||||
#[derive(Debug, Error)]
|
||||
enum Error {
|
||||
#[error("Candidate is not found")]
|
||||
CandidateNotFound,
|
||||
#[error("Signature is invalid")]
|
||||
InvalidSignature,
|
||||
StoreFailed,
|
||||
#[from]
|
||||
Erasure(erasure_coding::Error),
|
||||
#[from]
|
||||
ValidationFailed(ValidationFailed),
|
||||
#[from]
|
||||
Oneshot(oneshot::Canceled),
|
||||
#[from]
|
||||
Mpsc(mpsc::SendError),
|
||||
#[from]
|
||||
UtilError(util::Error),
|
||||
#[error("Failed to send candidates {0:?}")]
|
||||
Send(Vec<NewBackedCandidate>),
|
||||
#[error("Oneshot never resolved")]
|
||||
Oneshot(#[from] #[source] oneshot::Canceled),
|
||||
#[error("Obtaining erasure chunks failed")]
|
||||
ObtainErasureChunks(#[from] #[source] erasure_coding::Error),
|
||||
#[error(transparent)]
|
||||
ValidationFailed(#[from] ValidationFailed),
|
||||
#[error(transparent)]
|
||||
Mpsc(#[from] mpsc::SendError),
|
||||
#[error(transparent)]
|
||||
UtilError(#[from] util::Error),
|
||||
}
|
||||
|
||||
/// Holds all data needed for candidate backing job operation.
|
||||
@@ -468,7 +474,7 @@ impl CandidateBackingJob {
|
||||
CandidateBackingMessage::GetBackedCandidates(_, tx) => {
|
||||
let backed = self.get_backed();
|
||||
|
||||
tx.send(backed).map_err(|_| oneshot::Canceled)?;
|
||||
tx.send(backed).map_err(|data| Error::Send(data))?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -640,7 +646,7 @@ impl CandidateBackingJob {
|
||||
)
|
||||
).await?;
|
||||
|
||||
rx.await?.map_err(|_| Error::StoreFailed)?;
|
||||
let _ = rx.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user