tendermint_light_node/
error.rs

1//! Error types
2
3use std::net;
4
5use anomaly::{BoxError, Context};
6
7/// Error type
8pub type Error = anomaly::Error<Kind>;
9
10/// Kinds of errors
11#[derive(Clone, Debug, thiserror::Error)]
12pub enum Kind {
13    /// Error when parsing an address.
14    #[error(transparent)]
15    AddrParse(#[from] net::AddrParseError),
16
17    /// Error in configuration file
18    #[error("config error")]
19    Config,
20
21    /// Input/output error
22    #[error("i/o error")]
23    Io,
24}
25
26impl Kind {
27    /// Add additional context (i.e. include a source error and capture a backtrace).
28    /// You can convert the resulting `Context` into an `Error` by calling `.into()`.
29    pub fn context(self, source: impl Into<BoxError>) -> Context<Self> {
30        Context::new(self, Some(source.into()))
31    }
32}