tor-chanmgr::Error: impl HasKind
This commit is contained in:
parent
2a471ffd1a
commit
0a1cda6886
|
@ -6,6 +6,8 @@ use std::sync::Arc;
|
|||
use futures::task::SpawnError;
|
||||
use thiserror::Error;
|
||||
|
||||
use tor_error::ErrorKind;
|
||||
|
||||
/// An error returned by a channel manager.
|
||||
#[derive(Debug, Error, Clone)]
|
||||
#[non_exhaustive]
|
||||
|
@ -63,3 +65,14 @@ impl<T> From<std::sync::PoisonError<T>> for Error {
|
|||
Error::Internal("Thread failed while holding lock")
|
||||
}
|
||||
}
|
||||
|
||||
impl tor_error::HasKind for Error {
|
||||
fn kind(&self) -> ErrorKind {
|
||||
use Error as E;
|
||||
use ErrorKind as EK;
|
||||
match self {
|
||||
E::Io { .. } => EK::TorConnectionFailed,
|
||||
_ => EK::TODO,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,14 @@ pub use internal::*;
|
|||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Display)]
|
||||
#[non_exhaustive]
|
||||
pub enum ErrorKind {
|
||||
/// Error connecting to the Tor network
|
||||
///
|
||||
/// Perhaps the local network is not working, or perhaps the chosen relay is not working
|
||||
/// properly. Not used for errors that occur within the Tor network, or accessing the public
|
||||
/// internet on the far side of Tor.
|
||||
#[display(fmt = "error connecting to Tor")]
|
||||
TorConnectionFailed,
|
||||
|
||||
/// IO error accessing local persistent state
|
||||
///
|
||||
/// Eg, disk full or permissions problem.
|
||||
|
|
Loading…
Reference in New Issue