From d598ea0fa7df2022724972c42201fdc7d9728029 Mon Sep 17 00:00:00 2001 From: nokazn <41154684+nokazn@users.noreply.github.com> Date: Sun, 11 Feb 2024 17:10:49 +0900 Subject: [PATCH] refactor: path in NotAccessibleError --- src/errors.rs | 4 ++-- src/utils/glob.rs | 2 +- src/utils/path.rs | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/errors.rs b/src/errors.rs index 1ed1d79..156b262 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -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())))] diff --git a/src/utils/glob.rs b/src/utils/glob.rs index 0e42d73..eb2d6eb 100644 --- a/src/utils/glob.rs +++ b/src/utils/glob.rs @@ -51,7 +51,7 @@ fn resolve_glob(pattern: String, enable_negate: bool) -> (Option>, 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); } diff --git a/src/utils/path.rs b/src/utils/path.rs index b1165a5..d0c046d 100644 --- a/src/utils/path.rs +++ b/src/utils/path.rs @@ -6,7 +6,6 @@ use std::{ }; use crate::errors::Error; -use crate::errors::Paths; pub fn to_absolute_path>(path: T) -> Result { let path = path.as_ref(); @@ -15,7 +14,7 @@ pub fn to_absolute_path>(path: T) -> Result { } else { current_dir() .map_err(|error| { - Error::NotAccessibleError(Paths::One(PathBuf::from("./"))) + Error::NotAccessibleError(PathBuf::from("./")) .log_debug(error) .log_warn(None) })? @@ -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()