mirror of https://github.com/zkat/miette.git
feat: add `from_err()` method to `Report`
This commit is contained in:
parent
d6b4558502
commit
284aad501c
|
|
@ -425,6 +425,14 @@ impl Report {
|
|||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
/// Construct a [`Report`] directly from an error-like type
|
||||
pub fn from_err<E>(err: E) -> Self
|
||||
where
|
||||
E: std::error::Error + Send + Sync + 'static,
|
||||
{
|
||||
super::DiagnosticError(Box::new(err)).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl<E> From<E> for Report
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use crate::{Diagnostic, Report};
|
|||
/// Errors. This is intended to be paired with [`IntoDiagnostic`].
|
||||
#[derive(Debug, Error)]
|
||||
#[error(transparent)]
|
||||
struct DiagnosticError(Box<dyn std::error::Error + Send + Sync + 'static>);
|
||||
pub(crate) struct DiagnosticError(pub(crate) Box<dyn std::error::Error + Send + Sync + 'static>);
|
||||
impl Diagnostic for DiagnosticError {}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue