This is an automated email from the ASF dual-hosted git repository. xuanwo pushed a commit to branch polish-details in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
commit 7350b9740d5233772d640799eaf189c7a0d42f90 Author: Xuanwo <[email protected]> AuthorDate: Thu Sep 14 15:50:26 2023 +0800 Polish error context Signed-off-by: Xuanwo <[email protected]> --- core/src/layers/error_context.rs | 45 ++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/core/src/layers/error_context.rs b/core/src/layers/error_context.rs index 1fd5e608c..9dae975f9 100644 --- a/core/src/layers/error_context.rs +++ b/core/src/layers/error_context.rs @@ -97,13 +97,13 @@ impl<A: Accessor> LayeredAccessor for ErrorContextAccessor<A> { self.inner .read(path, args) - .map_ok(|(rp, os)| { + .map_ok(|(rp, r)| { ( rp, ErrorContextWrapper { scheme: self.meta.scheme(), path: path.to_string(), - inner: os, + inner: r, }, ) }) @@ -119,13 +119,13 @@ impl<A: Accessor> LayeredAccessor for ErrorContextAccessor<A> { async fn write(&self, path: &str, args: OpWrite) -> Result<(RpWrite, Self::Writer)> { self.inner .write(path, args) - .map_ok(|(rp, os)| { + .map_ok(|(rp, w)| { ( rp, ErrorContextWrapper { scheme: self.meta.scheme(), path: path.to_string(), - inner: os, + inner: w, }, ) }) @@ -186,13 +186,13 @@ impl<A: Accessor> LayeredAccessor for ErrorContextAccessor<A> { async fn list(&self, path: &str, args: OpList) -> Result<(RpList, Self::Pager)> { self.inner .list(path, args) - .map_ok(|(rp, os)| { + .map_ok(|(rp, p)| { ( rp, ErrorContextWrapper { scheme: self.meta.scheme(), path: path.to_string(), - inner: os, + inner: p, }, ) }) @@ -204,14 +204,6 @@ impl<A: Accessor> LayeredAccessor for ErrorContextAccessor<A> { .await } - async fn presign(&self, path: &str, args: OpPresign) -> Result<RpPresign> { - self.inner.presign(path, args).await.map_err(|err| { - err.with_operation(Operation::Presign) - .with_context("service", self.meta.scheme()) - .with_context("path", path) - }) - } - async fn batch(&self, args: OpBatch) -> Result<RpBatch> { self.inner .batch(args) @@ -238,6 +230,14 @@ impl<A: Accessor> LayeredAccessor for ErrorContextAccessor<A> { .await } + async fn presign(&self, path: &str, args: OpPresign) -> Result<RpPresign> { + self.inner.presign(path, args).await.map_err(|err| { + err.with_operation(Operation::Presign) + .with_context("service", self.meta.scheme()) + .with_context("path", path) + }) + } + fn blocking_create_dir(&self, path: &str, args: OpCreateDir) -> Result<RpCreateDir> { self.inner.blocking_create_dir(path, args).map_err(|err| { err.with_operation(Operation::BlockingCreateDir) @@ -353,6 +353,7 @@ impl<T: oio::Read> oio::Read for ErrorContextWrapper<T> { err.with_operation(ReadOperation::Read) .with_context("service", self.scheme) .with_context("path", &self.path) + .with_context("read_buf", buf.len().to_string()) }) } @@ -379,6 +380,7 @@ impl<T: oio::BlockingRead> oio::BlockingRead for ErrorContextWrapper<T> { err.with_operation(ReadOperation::BlockingRead) .with_context("service", self.scheme) .with_context("path", &self.path) + .with_context("read_buf", buf.len().to_string()) }) } @@ -387,6 +389,7 @@ impl<T: oio::BlockingRead> oio::BlockingRead for ErrorContextWrapper<T> { err.with_operation(ReadOperation::BlockingSeek) .with_context("service", self.scheme) .with_context("path", &self.path) + .with_context("seek", format!("{pos:?}")) }) } @@ -408,20 +411,21 @@ impl<T: oio::Write> oio::Write for ErrorContextWrapper<T> { err.with_operation(WriteOperation::Write) .with_context("service", self.scheme) .with_context("path", &self.path) + .with_context("write_buf", bs.remaining().to_string()) }) } - fn poll_abort(&mut self, cx: &mut Context<'_>) -> Poll<Result<()>> { - self.inner.poll_abort(cx).map_err(|err| { - err.with_operation(WriteOperation::Abort) + fn poll_close(&mut self, cx: &mut Context<'_>) -> Poll<Result<()>> { + self.inner.poll_close(cx).map_err(|err| { + err.with_operation(WriteOperation::Close) .with_context("service", self.scheme) .with_context("path", &self.path) }) } - fn poll_close(&mut self, cx: &mut Context<'_>) -> Poll<Result<()>> { - self.inner.poll_close(cx).map_err(|err| { - err.with_operation(WriteOperation::Close) + fn poll_abort(&mut self, cx: &mut Context<'_>) -> Poll<Result<()>> { + self.inner.poll_abort(cx).map_err(|err| { + err.with_operation(WriteOperation::Abort) .with_context("service", self.scheme) .with_context("path", &self.path) }) @@ -434,6 +438,7 @@ impl<T: oio::BlockingWrite> oio::BlockingWrite for ErrorContextWrapper<T> { err.with_operation(WriteOperation::BlockingWrite) .with_context("service", self.scheme) .with_context("path", &self.path) + .with_context("write_buf", bs.remaining().to_string()) }) }
