channel errors: Include what we were doing
This commit is contained in:
parent
5b54d3e08e
commit
6c2f9dac16
|
@ -82,13 +82,20 @@ impl<R: Runtime> ChanBuilder<R> {
|
|||
.record_attempt();
|
||||
}
|
||||
|
||||
let map_ioe = |ioe: io::Error| Error::Io {
|
||||
peer: *addr,
|
||||
source: ioe.into(),
|
||||
let map_ioe = |action: &'static str| {
|
||||
move |ioe: io::Error| Error::Io {
|
||||
action,
|
||||
peer: *addr,
|
||||
source: ioe.into(),
|
||||
}
|
||||
};
|
||||
|
||||
// Establish a TCP connection.
|
||||
let stream = self.runtime.connect(addr).await.map_err(map_ioe)?;
|
||||
let stream = self
|
||||
.runtime
|
||||
.connect(addr)
|
||||
.await
|
||||
.map_err(map_ioe("connect"))?;
|
||||
|
||||
{
|
||||
self.event_sender
|
||||
|
@ -102,11 +109,11 @@ impl<R: Runtime> ChanBuilder<R> {
|
|||
.tls_connector
|
||||
.negotiate_unvalidated(stream, "ignored")
|
||||
.await
|
||||
.map_err(map_ioe)?;
|
||||
.map_err(map_ioe("TLS negotiation"))?;
|
||||
|
||||
let peer_cert = tls
|
||||
.peer_certificate()
|
||||
.map_err(map_ioe)?
|
||||
.map_err(map_ioe("TLS certs"))?
|
||||
.ok_or(Error::Internal("TLS connection with no peer certificate"))?;
|
||||
|
||||
{
|
||||
|
|
|
@ -29,15 +29,13 @@ pub enum Error {
|
|||
Proto(#[from] tor_proto::Error),
|
||||
|
||||
/// Network IO error or TLS error
|
||||
#[error("Network IO error, or TLS error, talking to {peer}")]
|
||||
#[error("Network IO error, or TLS error, in {action}, talking to {peer}")]
|
||||
Io {
|
||||
/// Who we were talking to
|
||||
peer: SocketAddr,
|
||||
|
||||
// TODO
|
||||
// /// What we were doing
|
||||
// action: &'static str,
|
||||
// as per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/262#note_2772820
|
||||
/// What we were doing
|
||||
action: &'static str,
|
||||
|
||||
/// What happened. Might be some TLS library error wrapped up in io::Error
|
||||
#[source]
|
||||
|
|
Loading…
Reference in New Issue