From c927717f2dfa252f67c2d85ab5056ce662ea0a28 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 18 Aug 2023 16:28:53 -0500 Subject: [PATCH] fix(cli): Report more errors through report system --- crates/typos-cli/src/file.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/typos-cli/src/file.rs b/crates/typos-cli/src/file.rs index 9061c5e49..07e14d1c4 100644 --- a/crates/typos-cli/src/file.rs +++ b/crates/typos-cli/src/file.rs @@ -696,10 +696,15 @@ fn walk_entry( let explicit = entry.depth() == 0; let (path, lookup_path) = if entry.is_stdin() { let path = std::path::Path::new("-"); - (path, std::env::current_dir()?) + let cwd = std::env::current_dir().map_err(|err| { + let kind = err.kind(); + std::io::Error::new(kind, "no current working directory".to_owned()) + })?; + (path, cwd) } else { let path = entry.path(); - (path, path.canonicalize()?) + let abs_path = report_result(path.canonicalize(), Some(path), reporter)?; + (path, abs_path) }; let policy = engine.policy(&lookup_path); checks.check_file(path, explicit, &policy, reporter)?;