ptmgr: Use anonymize_home when displaying paths in errors

This commit is contained in:
Nick Mathewson 2022-11-29 19:30:50 -05:00
parent f6311c83f7
commit 9765fdc2e6
3 changed files with 6 additions and 3 deletions

1
Cargo.lock generated
View File

@ -4086,6 +4086,7 @@ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
"derive_builder_fork_arti", "derive_builder_fork_arti",
"fs-mistrust",
"futures", "futures",
"serde", "serde",
"thiserror", "thiserror",

View File

@ -22,6 +22,7 @@ experimental-api = ["visibility"]
[dependencies] [dependencies]
async-trait = "0.1.2" async-trait = "0.1.2"
derive_builder = { version = "0.11.2", package = "derive_builder_fork_arti" } derive_builder = { version = "0.11.2", package = "derive_builder_fork_arti" }
fs-mistrust = { version = "0.5.1", path = "../fs-mistrust" }
futures = "0.3.14" futures = "0.3.14"
serde = { version = "1.0.103", features = ["derive"] } serde = { version = "1.0.103", features = ["derive"] }
thiserror = "1" thiserror = "1"

View File

@ -1,5 +1,6 @@
//! Errors to do with pluggable transports. //! Errors to do with pluggable transports.
use fs_mistrust::anon_home::PathExt as _;
use futures::task::SpawnError; use futures::task::SpawnError;
use std::path::PathBuf; use std::path::PathBuf;
use std::sync::Arc; use std::sync::Arc;
@ -46,7 +47,7 @@ pub enum PtError {
#[error("Failed to read from PT binary: {0}")] #[error("Failed to read from PT binary: {0}")]
ChildReadFailed(Arc<std::io::Error>), ChildReadFailed(Arc<std::io::Error>),
/// We couldn't spawn a pluggable transport binary as a child process. /// We couldn't spawn a pluggable transport binary as a child process.
#[error("Couldn't execute PT binary at {}: {}", path.to_string_lossy(), error)] #[error("Couldn't execute PT binary at {}: {}", path.anonymize_home(), error)]
ChildSpawnFailed { ChildSpawnFailed {
/// The binary path we tried to execute. /// The binary path we tried to execute.
path: PathBuf, path: PathBuf,
@ -63,7 +64,7 @@ pub enum PtError {
error: String, error: String,
}, },
/// We couldn't create a state directory. /// We couldn't create a state directory.
#[error("Failed to create a state directory at {}: {}", path.to_string_lossy(), error)] #[error("Failed to create a state directory at {}: {}", path.anonymize_home(), error)]
StatedirCreateFailed { StatedirCreateFailed {
/// The offending path. /// The offending path.
path: PathBuf, path: PathBuf,
@ -81,7 +82,7 @@ pub enum PtError {
error: CfgPathError, error: CfgPathError,
}, },
/// A binary path was a directory or something instead of a file. /// A binary path was a directory or something instead of a file.
#[error("Configured binary path {} isn't a file", path.to_string_lossy())] #[error("Configured binary path {} isn't a file", path.anonymize_home())]
NotAFile { NotAFile {
/// The offending path. /// The offending path.
path: PathBuf, path: PathBuf,