summaryrefslogtreecommitdiff
path: root/crates/tor-netdir/src/err.rs
blob: 40567ae65bfb47629398172d8e5862e6ce99b298 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//! Declare error type for tor-netdir

use thiserror::Error;

/// An error returned by the network directory code
#[derive(Error, Debug)]
#[non_exhaustive]
pub enum Error {
    /// Problem reading a document from disk.
    #[error("io error: {0:?}")]
    Io(#[from] std::io::Error),
    /// Incorrect signature on a document.
    #[error("bad signature")]
    Sig(#[from] signature::Error),
    /// An object is expired or not yet valid.
    #[error("not currently valid: {0}")]
    Untimely(#[from] tor_checkable::TimeValidityError),
    /// We received a document we didn't want at all.
    #[error("unwanted object: {0}")]
    Unwanted(&'static str),
    /// A document was completely unreadable.
    #[error("bad document: {0}")]
    BadDoc(#[from] tor_netdoc::Error),
    /// A bad argument was provided to some configuration function.
    #[error("bad argument: {0}")]
    BadArgument(&'static str),
    /// We couldn't read something from disk that we should have been
    /// able to read.
    #[error("corrupt cache: {0}")]
    CacheCorruption(&'static str),
    /// We don't have enough directory info to build circuits
    #[error("not enough directory information to build circuits")]
    NotEnoughInfo,
}