Skip to content

Commit

Permalink
refactor: path in NotAccessibleError
Browse files Browse the repository at this point in the history
  • Loading branch information
nokazn committed Feb 11, 2024
1 parent 027b3f7 commit d598ea0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use crate::utils::path::to_absolute_path;

#[derive(Debug, Error)]
pub enum Error {
#[error("Cannot access to a file or a directory: `{}`", stringify_path(.0))]
NotAccessibleError(Paths),
#[error("Cannot access to a file or a directory: `{}`", stringify_path(&Paths::One(.0.to_path_buf())))]
NotAccessibleError(PathBuf),
#[error("No such a file or a directory: `{}`", stringify_path(.0))]
NoEntryError(Paths),
#[error("No lockfile at: `{}`", stringify_path(&Paths::One(.0.to_path_buf())))]
Expand Down
2 changes: 1 addition & 1 deletion src/utils/glob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn resolve_glob(pattern: String, enable_negate: bool) -> (Option<Vec<PathBuf>>,
let entries = entries
.filter_map(|entry| {
if let Err(error) = &entry {
Error::NotAccessibleError(Paths::One(error.path().to_path_buf()))
Error::NotAccessibleError(error.path().to_path_buf())
.log_debug(error)
.log_warn(None);
}
Expand Down
5 changes: 2 additions & 3 deletions src/utils/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::{
};

use crate::errors::Error;
use crate::errors::Paths;

pub fn to_absolute_path<T: AsRef<Path>>(path: T) -> Result<PathBuf, Error> {
let path = path.as_ref();
Expand All @@ -15,7 +14,7 @@ pub fn to_absolute_path<T: AsRef<Path>>(path: T) -> Result<PathBuf, Error> {
} else {
current_dir()
.map_err(|error| {
Error::NotAccessibleError(Paths::One(PathBuf::from("./")))
Error::NotAccessibleError(PathBuf::from("./"))
.log_debug(error)
.log_warn(None)
})?
Expand All @@ -32,7 +31,7 @@ where
U: Default,
{
let on_io_error = |error: io::Error| {
Error::NotAccessibleError(Paths::One(base_dir.as_ref().to_path_buf()))
Error::NotAccessibleError(base_dir.as_ref().to_path_buf())
.log_debug(&error)
.log_error(None);
fallback.unwrap_or_default()
Expand Down

0 comments on commit d598ea0

Please sign in to comment.