From a2b0c1d8f39c01749821a4b25a2df8a313123176 Mon Sep 17 00:00:00 2001 From: Bugen Zhao Date: Fri, 16 May 2025 13:51:05 +0800 Subject: [PATCH] chore: introduce `nightly` feature flag to provide error backtrace Signed-off-by: Bugen Zhao --- crates/iceberg/Cargo.toml | 2 ++ crates/iceberg/src/error.rs | 7 +++++++ crates/iceberg/src/lib.rs | 1 + 3 files changed, 10 insertions(+) diff --git a/crates/iceberg/Cargo.toml b/crates/iceberg/Cargo.toml index 471b0cbe9..463abdbb0 100644 --- a/crates/iceberg/Cargo.toml +++ b/crates/iceberg/Cargo.toml @@ -41,6 +41,8 @@ storage-s3 = ["opendal/services-s3"] async-std = ["dep:async-std"] tokio = ["tokio/rt-multi-thread"] +nightly = [] + [dependencies] anyhow = { workspace = true } apache-avro = { workspace = true } diff --git a/crates/iceberg/src/error.rs b/crates/iceberg/src/error.rs index 88410826f..f2e42fc0d 100644 --- a/crates/iceberg/src/error.rs +++ b/crates/iceberg/src/error.rs @@ -211,6 +211,13 @@ impl std::error::Error for Error { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { self.source.as_ref().map(|v| v.as_ref()) } + + #[cfg(feature = "nightly")] + fn provide<'a>(&'a self, request: &mut std::error::Request<'a>) { + if self.backtrace.status() == BacktraceStatus::Captured { + request.provide_ref::(&self.backtrace); + } + } } impl Error { diff --git a/crates/iceberg/src/lib.rs b/crates/iceberg/src/lib.rs index 556ff3e02..ddbb8c8f2 100644 --- a/crates/iceberg/src/lib.rs +++ b/crates/iceberg/src/lib.rs @@ -51,6 +51,7 @@ //! } //! ``` +#![cfg_attr(feature = "nightly", feature(error_generic_member_access))] #![deny(missing_docs)] #[macro_use]