nakamoto_client/
error.rs

1//! Node error module.
2use std::io;
3
4use crossbeam_channel as chan;
5use thiserror::Error;
6
7use nakamoto_chain as chain;
8use nakamoto_common as common;
9use nakamoto_p2p as p2p;
10
11use p2p::fsm::Command;
12
13/// A client error.
14#[derive(Error, Debug)]
15pub enum Error {
16    /// An error occuring from a client handle.
17    #[error(transparent)]
18    Handle(#[from] crate::handle::Error),
19    /// An error coming from the networking sub-system.
20    #[error(transparent)]
21    Net(#[from] nakamoto_net::error::Error),
22    /// A chain-related error.
23    #[error(transparent)]
24    Chain(#[from] common::block::tree::Error),
25    /// An I/O error.
26    #[error(transparent)]
27    Io(#[from] io::Error),
28    /// An error coming from the block store.
29    #[error(transparent)]
30    BlockStore(#[from] common::block::store::Error),
31    /// An error coming from the filter store.
32    #[error(transparent)]
33    FilterStore(#[from] chain::filter::store::Error),
34    /// An error coming from the peer store.
35    #[error("error loading peers: {0}")]
36    PeerStore(io::Error),
37    /// A communication channel error.
38    #[error("command channel disconnected")]
39    Channel,
40}
41
42impl From<chan::SendError<Command>> for Error {
43    fn from(_: chan::SendError<Command>) -> Self {
44        Self::Channel
45    }
46}
47
48impl From<chan::RecvError> for Error {
49    fn from(_: chan::RecvError) -> Self {
50        Self::Channel
51    }
52}