Skip to content
Myr

refactor: Get io error from method

Before adoption: this commit came in with the history the project adopted, so no landing records it.

use `ignore::Error::io_error()` to inspect the `std::io::Error` insted of pattern matching on `ignore::Error::Io`. This avoids relying on the implementation of ignore and how it organizes the error. In particular, this would allow us to handle if the IO error was wrapped in a `WithDepth`, as would be the case if BurntSushi/ripgrep#3458 was merged. This also allows us to remove some duplicate code.

authored by Thayne McCombs · committed by Thayne McCombs · parent 95dc645 · Browse files · 1 file+10 added−20 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+10 added−20 removed

  • other:+10 added−20 removed

1 file+10 added−20 removed

modified:src/walk.rs+10 added-20 removed
485 unmodified lines
486 Ok(e) => DirEntry::normal(e),487 Err(ignore::Error::WithPath {488 path,489 err: inner_err,490 }) => match inner_err.as_ref() {491 ignore::Error::Io(io_error)492 if io_error.kind() == io::ErrorKind::NotFound493 && path494 .symlink_metadata()495 .ok()496 .is_some_and(|m| m.file_type().is_symlink()) =>497 {498 DirEntry::broken_symlink(path)499 }500 _ => {501 return match tx.send(WorkerResult::Error(ignore::Error::WithPath {502 path,503 err: inner_err,504 })) {505 Ok(_) => WalkState::Continue,506 Err(_) => WalkState::Quit,507 };508 }509 },490 }) if inner_err491 .io_error()492 .is_some_and(|io_error| io_error.kind() == io::ErrorKind::NotFound)493 && path494 .symlink_metadata()495 .ok()496 .is_some_and(|m| m.file_type().is_symlink()) =>497 {498 DirEntry::broken_symlink(path)499 }500 Err(err) => {501 return match tx.send(WorkerResult::Error(err)) {502 Ok(_) => WalkState::Continue,503 Err(_) => WalkState::Quit,
241 unmodified lines