mirror of
https://github.com/crate-ci/typos.git
synced 2026-11-14 01:53:54 +01:00
fix: Return more precise errors
This commit is contained in:
1 parent
8ecffe79e3
commit
b03df3aeae
4 files changed
+63
-46
No files matched your search
+4
-4
@@ -4,7 +4,7 @@ pub(crate) fn check_path(
|
||||
parser: &typos::tokens::Parser,
|
||||
dictionary: &dyn typos::Dictionary,
|
||||
reporter: &dyn typos::report::Report,
|
||||
) -> Result<(), anyhow::Error> {
|
||||
) -> Result<(), ignore::Error> {
|
||||
for entry in walk {
|
||||
check_entry(entry, checks, parser, dictionary, reporter)?;
|
||||
}
|
||||
@@ -17,8 +17,8 @@ pub(crate) fn check_path_parallel(
|
||||
parser: &typos::tokens::Parser,
|
||||
dictionary: &dyn typos::Dictionary,
|
||||
reporter: &dyn typos::report::Report,
|
||||
) -> Result<(), anyhow::Error> {
|
||||
let error: std::sync::Mutex<Result<(), anyhow::Error>> = std::sync::Mutex::new(Ok(()));
|
||||
) -> Result<(), ignore::Error> {
|
||||
let error: std::sync::Mutex<Result<(), ignore::Error>> = std::sync::Mutex::new(Ok(()));
|
||||
walk.run(|| {
|
||||
Box::new(|entry: Result<ignore::DirEntry, ignore::Error>| {
|
||||
match check_entry(entry, checks, parser, dictionary, reporter) {
|
||||
@@ -40,7 +40,7 @@ fn check_entry(
|
||||
parser: &typos::tokens::Parser,
|
||||
dictionary: &dyn typos::Dictionary,
|
||||
reporter: &dyn typos::report::Report,
|
||||
) -> Result<(), anyhow::Error> {
|
||||
) -> Result<(), ignore::Error> {
|
||||
let entry = entry?;
|
||||
if entry.file_type().map(|t| t.is_file()).unwrap_or(true) {
|
||||
let explicit = entry.depth() == 0;
|
||||
|
||||
+10
-6
@@ -13,14 +13,14 @@ mod dict;
|
||||
mod diff;
|
||||
mod replace;
|
||||
|
||||
use proc_exit::ProcessExitResultExt;
|
||||
use proc_exit::WithCodeResultExt;
|
||||
|
||||
fn main() {
|
||||
run().process_exit();
|
||||
let result = run();
|
||||
proc_exit::exit(result);
|
||||
}
|
||||
|
||||
fn run() -> Result<(), proc_exit::Exit> {
|
||||
fn run() -> proc_exit::ExitResult {
|
||||
// clap's `get_matches` uses Failure rather than Usage, so bypass it for `get_matches_safe`.
|
||||
let args = match args::Args::from_args_safe() {
|
||||
Ok(args) => args,
|
||||
@@ -29,7 +29,7 @@ fn run() -> Result<(), proc_exit::Exit> {
|
||||
}
|
||||
Err(e) => {
|
||||
writeln!(std::io::stdout(), "{}", e)?;
|
||||
return Ok(());
|
||||
return proc_exit::Code::SUCCESS.ok();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -130,7 +130,6 @@ fn run() -> Result<(), proc_exit::Exit> {
|
||||
&dictionary,
|
||||
reporter,
|
||||
)
|
||||
.with_code(proc_exit::Code::FAILURE)?;
|
||||
} else {
|
||||
checks::check_path_parallel(
|
||||
walk.build_parallel(),
|
||||
@@ -139,8 +138,13 @@ fn run() -> Result<(), proc_exit::Exit> {
|
||||
&dictionary,
|
||||
reporter,
|
||||
)
|
||||
.with_code(proc_exit::Code::FAILURE)?;
|
||||
}
|
||||
.map_err(|e| {
|
||||
e.io_error()
|
||||
.map(|i| proc_exit::Code::from(i.kind()))
|
||||
.unwrap_or_default()
|
||||
.with_message(e)
|
||||
})?;
|
||||
if status_reporter.typos_found() {
|
||||
typos_found = true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user