From c04ed4911f35d464503c635c6a868c86a5cb7ef8 Mon Sep 17 00:00:00 2001 From: Wei Zhang Date: Sat, 25 Mar 2023 00:18:16 +0800 Subject: [PATCH] chore: improve NotADirectory error message with ending slash Signed-off-by: Wei Zhang --- core/src/types/operator/blocking_operator.rs | 17 +++++++++-------- core/src/types/operator/operator.rs | 17 +++++++++-------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/core/src/types/operator/blocking_operator.rs b/core/src/types/operator/blocking_operator.rs index 0238c3148c3..a4809cfb15f 100644 --- a/core/src/types/operator/blocking_operator.rs +++ b/core/src/types/operator/blocking_operator.rs @@ -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() @@ -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()) @@ -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()) diff --git a/core/src/types/operator/operator.rs b/core/src/types/operator/operator.rs index 9ede09f41fa..61bbfe31764 100644 --- a/core/src/types/operator/operator.rs +++ b/core/src/types/operator/operator.rs @@ -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() @@ -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()) @@ -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())