mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 15:51:12 +00:00
use thiserror instead of derive_more for error handling (#10696)
* use thiserror instead of derive_more for error handling Signed-off-by: koushiro <koushiro.cqx@gmail.com> * Update utils/prometheus/src/lib.rs * Update utils/prometheus/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -884,34 +884,35 @@ impl NetworkBehaviour for RequestResponsesBehaviour {
|
||||
}
|
||||
|
||||
/// Error when registering a protocol.
|
||||
#[derive(Debug, derive_more::Display, derive_more::Error)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum RegisterError {
|
||||
/// A protocol has been specified multiple times.
|
||||
DuplicateProtocol(#[error(ignore)] Cow<'static, str>),
|
||||
#[error("{0}")]
|
||||
DuplicateProtocol(Cow<'static, str>),
|
||||
}
|
||||
|
||||
/// Error in a request.
|
||||
#[derive(Debug, derive_more::Display, derive_more::Error)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[allow(missing_docs)]
|
||||
pub enum RequestFailure {
|
||||
/// We are not currently connected to the requested peer.
|
||||
#[error("We are not currently connected to the requested peer.")]
|
||||
NotConnected,
|
||||
/// Given protocol hasn't been registered.
|
||||
#[error("Given protocol hasn't been registered.")]
|
||||
UnknownProtocol,
|
||||
/// Remote has closed the substream before answering, thereby signaling that it considers the
|
||||
/// request as valid, but refused to answer it.
|
||||
#[error("Remote has closed the substream before answering, thereby signaling that it considers the request as valid, but refused to answer it.")]
|
||||
Refused,
|
||||
/// The remote replied, but the local node is no longer interested in the response.
|
||||
#[error("The remote replied, but the local node is no longer interested in the response.")]
|
||||
Obsolete,
|
||||
/// Problem on the network.
|
||||
#[display(fmt = "Problem on the network: {}", _0)]
|
||||
#[error("Problem on the network: {0}")]
|
||||
Network(OutboundFailure),
|
||||
}
|
||||
|
||||
/// Error when processing a request sent by a remote.
|
||||
#[derive(Debug, derive_more::Display, derive_more::Error)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum ResponseFailure {
|
||||
/// Problem on the network.
|
||||
#[display(fmt = "Problem on the network: {}", _0)]
|
||||
#[error("Problem on the network: {0}")]
|
||||
Network(InboundFailure),
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user