circmgr: Port InternalError to use Bug.
This commit is contained in:
parent
f572baa7ad
commit
900007585a
|
@ -6,7 +6,7 @@ use futures::task::SpawnError;
|
|||
use retry_error::RetryError;
|
||||
use thiserror::Error;
|
||||
|
||||
use tor_error::ErrorKind;
|
||||
use tor_error::{Bug, ErrorKind};
|
||||
use tor_linkspec::OwnedChanTarget;
|
||||
|
||||
/// An error returned while looking up or building a circuit
|
||||
|
@ -55,10 +55,10 @@ pub enum Error {
|
|||
#[error("Circuit cancelled")]
|
||||
CircCancelled,
|
||||
|
||||
/// An error caused by a programming issue or a failure in another
|
||||
/// An error caused by a programming issue . or a failure in another
|
||||
/// library that we can't work around.
|
||||
#[error("Internal error: {0}")]
|
||||
Internal(String),
|
||||
#[error("Programming issue: {0}")]
|
||||
Bug(#[from] Bug),
|
||||
|
||||
/// Problem with channel
|
||||
#[error("Problem with channel to {peer}")]
|
||||
|
@ -129,6 +129,7 @@ impl tor_error::HasKind for Error {
|
|||
use ErrorKind as EK;
|
||||
match self {
|
||||
E::Channel { cause, .. } => cause.kind(),
|
||||
E::Bug(e) => e.kind(),
|
||||
_ => EK::TODO,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ use async_trait::async_trait;
|
|||
use futures::future::OptionFuture;
|
||||
use std::convert::TryInto;
|
||||
use std::sync::Arc;
|
||||
use tor_error::internal;
|
||||
use tor_proto::circuit::{CircParameters, ClientCirc};
|
||||
use tor_rtcompat::Runtime;
|
||||
|
||||
|
@ -111,7 +112,7 @@ impl<R: Runtime> crate::mgr::AbstractCircBuilder for crate::build::CircuitBuilde
|
|||
Some(Ok(true)) | None => (),
|
||||
Some(Ok(false)) => return Err(Error::GuardNotUsable),
|
||||
Some(Err(_)) => {
|
||||
return Err(Error::Internal("Guard usability status cancelled".into()))
|
||||
return Err(internal!("Guard usability status cancelled").into());
|
||||
}
|
||||
}
|
||||
Ok((final_spec, circuit))
|
||||
|
|
|
@ -4,6 +4,7 @@ use super::TorPath;
|
|||
use crate::{DirInfo, Error, PathConfig, Result, TargetPort};
|
||||
use rand::Rng;
|
||||
use std::time::{Duration, SystemTime};
|
||||
use tor_error::internal;
|
||||
use tor_guardmgr::{GuardMgr, GuardMonitor, GuardUsable};
|
||||
use tor_netdir::{NetDir, Relay, SubnetConfig, WeightRole};
|
||||
use tor_rtcompat::Runtime;
|
||||
|
@ -158,7 +159,10 @@ impl<'a> ExitPathBuilder<'a> {
|
|||
let guard_usage = b.build().expect("Failed while building guard usage!");
|
||||
let (guard, mut mon, usable) = guardmgr.select_guard(guard_usage, Some(netdir))?;
|
||||
let guard = guard.get_relay(netdir).ok_or_else(|| {
|
||||
Error::Internal("Somehow the guardmgr gave us an unlisted guard!".to_owned())
|
||||
Error::Bug(internal!(
|
||||
"Somehow the guardmgr gave us an unlisted guard {:?}!",
|
||||
guard
|
||||
))
|
||||
})?;
|
||||
if !path_is_fully_random {
|
||||
// We were given a specific exit relay to use, and
|
||||
|
|
Loading…
Reference in New Issue