From ab95723d82f18d2383b18aa764f58717810b8814 Mon Sep 17 00:00:00 2001 From: kalzoo <22137047+kalzoo@users.noreply.github.com> Date: Sun, 26 Feb 2023 12:43:40 -0800 Subject: [PATCH 1/4] error: impl Clone for TracedError where E: Clone --- tracing-error/src/error.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tracing-error/src/error.rs b/tracing-error/src/error.rs index 8d25401a3e..42106506e6 100644 --- a/tracing-error/src/error.rs +++ b/tracing-error/src/error.rs @@ -181,6 +181,12 @@ where } } +impl std::clone::Clone for TracedError where E: Clone { + fn clone(&self) -> Self { + Self { inner: self.inner.clone() } + } +} + impl From for TracedError where E: Error + Send + Sync + 'static, @@ -213,6 +219,12 @@ impl ErrorImpl { } } +impl Clone for ErrorImpl where E: Clone { + fn clone(&self) -> Self { + Self { vtable: self.vtable, span_trace: self.span_trace.clone(), error: self.error.clone() } + } +} + struct ErrorVTable { object_ref: unsafe fn(&ErrorImpl) -> &(dyn Error + Send + Sync + 'static), } From 6d6aeb0752197fa6773d16cb7763a032832bf132 Mon Sep 17 00:00:00 2001 From: kalzoo <22137047+kalzoo@users.noreply.github.com> Date: Sun, 26 Feb 2023 12:25:43 -0800 Subject: [PATCH 2/4] error: provide access to inner error within TracedError This change makes TracedError a two-way door, making it easier to adopt in a larger codebase. This change provides an "escape hatch" to be able to read and extract error stored within a TracedError. Among other things, this will help adoption of TracedError by: * allowing onboarding users to still match against error variants, as might be common in test cases * allowing crate users to bypass missing or unreleased features * allowing for partial migration of a codebase, so that TracedError can be used in one portion, and then the original error extracted at some interface above which TracedError is not yet used or wanted. --- tracing-error/src/error.rs | 44 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tracing-error/src/error.rs b/tracing-error/src/error.rs index 42106506e6..047cb49952 100644 --- a/tracing-error/src/error.rs +++ b/tracing-error/src/error.rs @@ -179,6 +179,50 @@ where { self.map(Into::into) } + + /// Return a reference to the original error stored within this [`TracedError`]. + /// + /// ```rust + /// use tracing_error::TracedError; + /// # #[derive(Clone, Debug, PartialEq)] + /// # struct MyError(u64); + /// # impl std::fmt::Display for MyError { + /// # fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + /// # write!(f, "Inner Error") + /// # } + /// # } + /// # impl std::error::Error for MyError {} + /// + /// let original_err = MyError(42); + /// + /// let traced_err: TracedError = TracedError::from(original_err.clone()); + /// assert_eq!(traced_err.get_inner_error(), &original_err) + /// ``` + pub fn get_inner_error(&self) -> &E { + &self.inner.error + } + + /// Consume the [`TracedError`] and return the original error stored within. + /// + /// ```rust + /// use tracing_error::TracedError; + /// # #[derive(Clone, Debug, PartialEq)] + /// # struct MyError(u64); + /// # impl std::fmt::Display for MyError { + /// # fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + /// # write!(f, "Inner Error") + /// # } + /// # } + /// # impl std::error::Error for MyError {} + /// + /// let original_err = MyError(42); + /// + /// let traced_err: TracedError = TracedError::from(original_err.clone()); + /// assert_eq!(traced_err.to_inner_error(), original_err) + /// ``` + pub fn to_inner_error(self) -> E { + self.inner.error + } } impl std::clone::Clone for TracedError where E: Clone { From 0723ed7257ee7fbe8e6fd5beeef26500180573a7 Mon Sep 17 00:00:00 2001 From: Kyle J Strand Date: Fri, 29 May 2026 13:23:26 -0600 Subject: [PATCH 3/4] cargo fmt --- tracing-error/src/error.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tracing-error/src/error.rs b/tracing-error/src/error.rs index 047cb49952..ca4bba6945 100644 --- a/tracing-error/src/error.rs +++ b/tracing-error/src/error.rs @@ -225,9 +225,14 @@ where } } -impl std::clone::Clone for TracedError where E: Clone { +impl std::clone::Clone for TracedError +where + E: Clone, +{ fn clone(&self) -> Self { - Self { inner: self.inner.clone() } + Self { + inner: self.inner.clone(), + } } } @@ -263,9 +268,16 @@ impl ErrorImpl { } } -impl Clone for ErrorImpl where E: Clone { +impl Clone for ErrorImpl +where + E: Clone, +{ fn clone(&self) -> Self { - Self { vtable: self.vtable, span_trace: self.span_trace.clone(), error: self.error.clone() } + Self { + vtable: self.vtable, + span_trace: self.span_trace.clone(), + error: self.error.clone(), + } } } From fb8f9833ec7bb9d6eeec4b5d2836e96c403aa9b7 Mon Sep 17 00:00:00 2001 From: Kyle J Strand Date: Mon, 15 Jun 2026 23:11:15 -0600 Subject: [PATCH 4/4] bump patch version --- tracing-error/Cargo.toml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tracing-error/Cargo.toml b/tracing-error/Cargo.toml index 9c2733e879..4ede52f402 100644 --- a/tracing-error/Cargo.toml +++ b/tracing-error/Cargo.toml @@ -1,11 +1,7 @@ [package] name = "tracing-error" -# When releasing to crates.io: -# - Remove path dependencies -# - Update doc url in README.md. -# - Update CHANGELOG.md. -# - Create "v0.2.x" git tag -version = "0.2.1" + # The '0.775' series is compatible with tracing-core 0.1, but is only published privately and used by Rigetti. +version = "0.775.0" authors = [ "Eliza Weisman ", "Jane Lusby ",