Skip to content

Commit 93d3bd1

Browse files
authored
feat(Report): add from_err() method to Report (#403)
1 parent d6b4558 commit 93d3bd1

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/eyreish/error.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,14 @@ impl Report {
425425
}
426426
.into()
427427
}
428+
429+
/// Construct a [`Report`] directly from an error-like type
430+
pub fn from_err<E>(err: E) -> Self
431+
where
432+
E: std::error::Error + Send + Sync + 'static,
433+
{
434+
super::DiagnosticError(Box::new(err)).into()
435+
}
428436
}
429437

430438
impl<E> From<E> for Report

src/eyreish/into_diagnostic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{Diagnostic, Report};
66
/// Errors. This is intended to be paired with [`IntoDiagnostic`].
77
#[derive(Debug, Error)]
88
#[error(transparent)]
9-
struct DiagnosticError(Box<dyn std::error::Error + Send + Sync + 'static>);
9+
pub(crate) struct DiagnosticError(pub(crate) Box<dyn std::error::Error + Send + Sync + 'static>);
1010
impl Diagnostic for DiagnosticError {}
1111

1212
/**

0 commit comments

Comments
 (0)