blob: d6e341049552a62ef742f896651a033bf86a63b4 (
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
//! Declare error types for tor-chanmgr
use std::sync::Arc;
use thiserror::Error;
/// An error returned by a channel manager.
#[derive(Debug, Error, Clone)]
#[non_exhaustive]
pub enum Error {
/// A ChanTarget was given for which no channel could be built.
#[error("Target was unusable: {0}")]
UnusableTarget(String),
/// We were waiting on a pending channel, but it didn't succeed.
#[error("Pending channel failed to launch")]
PendingFailed,
/// It took too long for us to establish this connection.
#[error("Channel timed out")]
ChanTimeout,
/// A protocol error while making a channel
#[error("Protocol error while opening a channel: {0}")]
Proto(#[from] tor_proto::Error),
/// A protocol error while making a channel
#[error("I/O error while opening a channel: {0}")]
Io(#[source] Arc<std::io::Error>),
/// An internal error of some kind that should never occur.
#[error("Internal error: {0}")]
Internal(&'static str),
}
impl From<futures::task::SpawnError> for Error {
fn from(_: futures::task::SpawnError) -> Error {
Error::Internal("Couldn't spawn channel reactor")
}
}
impl From<tor_rtcompat::TimeoutError> for Error {
fn from(_: tor_rtcompat::TimeoutError) -> Error {
Error::ChanTimeout
}
}
impl<T> From<std::sync::PoisonError<T>> for Error {
fn from(_: std::sync::PoisonError<T>) -> Error {
Error::Internal("Thread failed while holding lock")
}
}
impl From<std::io::Error> for Error {
fn from(e: std::io::Error) -> Error {
Error::Io(Arc::new(e))
}
}
|