Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve NotADirectory error message with ending slash #1756

Merged
merged 1 commit into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions core/src/types/operator/blocking_operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,13 @@ impl BlockingOperator {
let path = normalize_path(path);

if !validate_path(&path, EntryMode::DIR) {
return Err(
Error::new(ErrorKind::NotADirectory, "read path is not a directory")
.with_operation("create_dir")
.with_context("service", self.inner().info().scheme())
.with_context("path", &path),
);
return Err(Error::new(
ErrorKind::NotADirectory,
"the path trying to create should end with `/`",
)
.with_operation("create_dir")
.with_context("service", self.inner().info().scheme())
.with_context("path", &path));
}

self.inner()
Expand Down Expand Up @@ -589,7 +590,7 @@ impl BlockingOperator {
if !validate_path(&path, EntryMode::DIR) {
return Err(Error::new(
ErrorKind::NotADirectory,
"the path trying to list is not a directory",
"the path trying to list should end with `/`",
)
.with_operation("BlockingOperator::list")
.with_context("service", self.info().scheme().into_static())
Expand Down Expand Up @@ -639,7 +640,7 @@ impl BlockingOperator {
if !validate_path(&path, EntryMode::DIR) {
return Err(Error::new(
ErrorKind::NotADirectory,
"the path trying to list is not a directory",
"the path trying to scan should end with `/`",
)
.with_operation("BlockingOperator::scan")
.with_context("service", self.info().scheme().into_static())
Expand Down
17 changes: 9 additions & 8 deletions core/src/types/operator/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,13 @@ impl Operator {
let path = normalize_path(path);

if !validate_path(&path, EntryMode::DIR) {
return Err(
Error::new(ErrorKind::NotADirectory, "read path is not a directory")
.with_operation("create_dir")
.with_context("service", self.inner().info().scheme())
.with_context("path", &path),
);
return Err(Error::new(
ErrorKind::NotADirectory,
"the path trying to create should end with `/`",
)
.with_operation("create_dir")
.with_context("service", self.inner().info().scheme())
.with_context("path", &path));
}

self.inner()
Expand Down Expand Up @@ -818,7 +819,7 @@ impl Operator {
if !validate_path(&path, EntryMode::DIR) {
return Err(Error::new(
ErrorKind::NotADirectory,
"the path trying to list is not a directory",
"the path trying to list should end with `/`",
)
.with_operation("Operator::list")
.with_context("service", self.info().scheme().into_static())
Expand Down Expand Up @@ -870,7 +871,7 @@ impl Operator {
if !validate_path(&path, EntryMode::DIR) {
return Err(Error::new(
ErrorKind::NotADirectory,
"the path trying to list is not a directory",
"the path trying to scan should end with `/`",
)
.with_operation("scan")
.with_context("service", self.info().scheme().into_static())
Expand Down