Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions src/compat/anyhow1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,6 @@ impl IntoRootcause for anyhow::Error {
}
}

impl<T> IntoRootcause for anyhow::Result<T> {
type Output = Result<T, Report>;

#[inline(always)]
fn into_rootcause(self) -> Self::Output {
self.map_err(|e| e.into_rootcause())
}
}

/// A trait for converting rootcause [`Report`]s into [`anyhow::Error`].
///
/// This trait provides the `.into_anyhow()` method for converting rootcause
Expand Down
18 changes: 0 additions & 18 deletions src/compat/boxed_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,21 +372,3 @@ impl IntoRootcause for Box<dyn Error> {
Report::new_local_custom::<BoxedErrorHandler>(self).into_dynamic()
}
}

impl<T> IntoRootcause for Result<T, Box<dyn Error + Send + Sync>> {
type Output = Result<T, Report>;

#[inline(always)]
fn into_rootcause(self) -> Self::Output {
self.map_err(|e| e.into_rootcause())
}
}

impl<T> IntoRootcause for Result<T, Box<dyn Error>> {
type Output = Result<T, Report<Dynamic, markers::Mutable, Local>>;

#[inline(always)]
fn into_rootcause(self) -> Self::Output {
self.map_err(|e| e.into_rootcause())
}
}
12 changes: 0 additions & 12 deletions src/compat/error_stack08.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,18 +214,6 @@ where
}
}

impl<T, C> IntoRootcause for Result<T, error_stack::Report<C>>
where
C: core::error::Error + Send + Sync + 'static,
{
type Output = Result<T, Report<error_stack::Report<C>>>;

#[inline(always)]
fn into_rootcause(self) -> Self::Output {
self.map_err(|e| e.into_rootcause())
}
}

/// A trait for converting rootcause [`Report`]s into [`error_stack::Report`].
///
/// This trait provides the `.into_error_stack()` method for converting
Expand Down
9 changes: 0 additions & 9 deletions src/compat/eyre06.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,6 @@ impl IntoRootcause for eyre::Report {
}
}

impl<T> IntoRootcause for eyre::Result<T> {
type Output = Result<T, Report>;

#[inline(always)]
fn into_rootcause(self) -> Self::Output {
self.map_err(|e| e.into_rootcause())
}
}

/// A trait for converting rootcause [`Report`]s into [`eyre::Report`].
///
/// This trait provides the `.into_eyre()` method for converting rootcause
Expand Down
15 changes: 15 additions & 0 deletions src/compat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,23 @@ pub trait IntoRootcause {
/// Box::new(std::io::Error::from(std::io::ErrorKind::NotFound));
/// let report: rootcause::Report = boxed.into_rootcause();
/// ```
#[track_caller]
fn into_rootcause(self) -> Self::Output;
}

impl<T, E: IntoRootcause> IntoRootcause for Result<T, E> {
type Output = Result<T, E::Output>;

#[inline]
fn into_rootcause(self) -> Self::Output {
// map_err doesn't work well with #[track_caller]
match self {
Self::Ok(t) => Ok(t),
Self::Err(e) => Err(e.into_rootcause()),
}
}
}

pub mod boxed_error;

#[cfg(feature = "compat-anyhow1")]
Expand Down Expand Up @@ -276,6 +290,7 @@ impl<C: ?Sized, T> From<ReportRef<'_, C, markers::Cloneable, T>> for ReportAsErr
pub struct MainReport(Report<Dynamic, Cloneable, Local>);

impl<E: IntoReport<Local>> From<E> for MainReport {
#[track_caller]
fn from(value: E) -> Self {
Self(value.into_report().into_dynamic().into_cloneable())
}
Expand Down