mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 22:37:57 +00:00
fatality based errors (#4448)
* seed commit for fatality based errors * fatality * first draft of fatality * cleanup * differnt approach * simplify * first working version for enums, with documentation * add split * fix simple split test case * extend README.md * update fatality impl * make tests passed * apply fatality to first subsystem * fatality fixes * use fatality in a subsystem * fix subsystemg * fixup proc macro * fix/test: log::*! do not execute when log handler is missing * fix spelling * rename Runtime2 to something sane * allow nested split with `forward` annotations * add free license * enable and fixup all tests * use external fatality Makes this more reviewable. * bump fatality dep Avoid duplicate expander compilations. * migrate availability distribution * more fatality usage * chore: bump fatality to 0.0.6 * fixup remaining subsystems * chore: fmt * make cargo spellcheck happy * remove single instance of `#[fatal(false)]` * last quality sweep * fixup
This commit is contained in:
committed by
GitHub
parent
85fa087405
commit
d946582707
@@ -15,7 +15,6 @@
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use futures::{channel::oneshot, prelude::Future};
|
||||
use thiserror::Error;
|
||||
|
||||
use parity_scale_codec::{Decode, Encode, Error as DecodingError};
|
||||
|
||||
@@ -79,19 +78,19 @@ impl Requests {
|
||||
pub type ResponseSender = oneshot::Sender<Result<Vec<u8>, network::RequestFailure>>;
|
||||
|
||||
/// Any error that can occur when sending a request.
|
||||
#[derive(Debug, Error)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum RequestError {
|
||||
/// Response could not be decoded.
|
||||
#[error("Response could not be decoded: {0}")]
|
||||
InvalidResponse(#[source] DecodingError),
|
||||
InvalidResponse(#[from] DecodingError),
|
||||
|
||||
/// Some error in substrate/libp2p happened.
|
||||
#[error("{0}")]
|
||||
NetworkError(#[source] network::RequestFailure),
|
||||
NetworkError(#[from] network::RequestFailure),
|
||||
|
||||
/// Response got canceled by networking.
|
||||
#[error("Response channel got canceled")]
|
||||
Canceled(#[source] oneshot::Canceled),
|
||||
Canceled(#[from] oneshot::Canceled),
|
||||
}
|
||||
|
||||
impl RequestError {
|
||||
@@ -180,21 +179,3 @@ where
|
||||
let raw = rec.await??;
|
||||
Ok(Decode::decode(&mut raw.as_ref())?)
|
||||
}
|
||||
|
||||
impl From<DecodingError> for RequestError {
|
||||
fn from(err: DecodingError) -> Self {
|
||||
Self::InvalidResponse(err)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<network::RequestFailure> for RequestError {
|
||||
fn from(err: network::RequestFailure) -> Self {
|
||||
Self::NetworkError(err)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<oneshot::Canceled> for RequestError {
|
||||
fn from(err: oneshot::Canceled) -> Self {
|
||||
Self::Canceled(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user