You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by ma...@apache.org on 2025/02/19 16:05:19 UTC

(opendal) branch main updated: feat(bindings/python) detailed error message (#5646)

This is an automated email from the ASF dual-hosted git repository.

manjusaka pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new d7ec17dba feat(bindings/python) detailed error message (#5646)
d7ec17dba is described below

commit d7ec17dbad2debe33760b4fbff0de240f0aa9cfa
Author: Asuka Minato <i...@asukaminato.eu.org>
AuthorDate: Thu Feb 20 01:05:13 2025 +0900

    feat(bindings/python) detailed error message (#5646)
    
    * format!({err:?})
    
    * Update errors.rs
    
    * prebuild err string
---
 bindings/python/src/errors.rs | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/bindings/python/src/errors.rs b/bindings/python/src/errors.rs
index 6a8be442a..575962cbf 100644
--- a/bindings/python/src/errors.rs
+++ b/bindings/python/src/errors.rs
@@ -58,17 +58,18 @@ create_exception!(
 );
 
 pub fn format_pyerr(err: ocore::Error) -> PyErr {
+    let e = format!("{err:?}");
     match err.kind() {
-        ocore::ErrorKind::Unexpected => Unexpected::new_err(err.to_string()),
-        ocore::ErrorKind::Unsupported => Unsupported::new_err(err.to_string()),
-        ocore::ErrorKind::ConfigInvalid => ConfigInvalid::new_err(err.to_string()),
-        ocore::ErrorKind::NotFound => NotFound::new_err(err.to_string()),
-        ocore::ErrorKind::PermissionDenied => PermissionDenied::new_err(err.to_string()),
-        ocore::ErrorKind::IsADirectory => IsADirectory::new_err(err.to_string()),
-        ocore::ErrorKind::NotADirectory => NotADirectory::new_err(err.to_string()),
-        ocore::ErrorKind::AlreadyExists => AlreadyExists::new_err(err.to_string()),
-        ocore::ErrorKind::IsSameFile => IsSameFile::new_err(err.to_string()),
-        ocore::ErrorKind::ConditionNotMatch => ConditionNotMatch::new_err(err.to_string()),
-        _ => Unexpected::new_err(err.to_string()),
+        ocore::ErrorKind::Unexpected => Unexpected::new_err(e),
+        ocore::ErrorKind::Unsupported => Unsupported::new_err(e),
+        ocore::ErrorKind::ConfigInvalid => ConfigInvalid::new_err(e),
+        ocore::ErrorKind::NotFound => NotFound::new_err(e),
+        ocore::ErrorKind::PermissionDenied => PermissionDenied::new_err(e),
+        ocore::ErrorKind::IsADirectory => IsADirectory::new_err(e),
+        ocore::ErrorKind::NotADirectory => NotADirectory::new_err(e),
+        ocore::ErrorKind::AlreadyExists => AlreadyExists::new_err(e),
+        ocore::ErrorKind::IsSameFile => IsSameFile::new_err(e),
+        ocore::ErrorKind::ConditionNotMatch => ConditionNotMatch::new_err(e),
+        _ => Unexpected::new_err(e),
     }
 }