mirror of https://github.com/zkat/miette.git
feat(report): `Report::new_boxed`
This is already currently accessible with `miette!`, but I missed that because it isn't clearly documented. Add a constructor to mirror `Report::new` and `Report::msg`.
This commit is contained in:
parent
5815eab310
commit
aee218757b
|
|
@ -73,6 +73,18 @@ impl Report {
|
||||||
Report::from_adhoc(message)
|
Report::from_adhoc(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create a new error object from a boxed [`Diagnostic`].
|
||||||
|
///
|
||||||
|
/// The boxed type must be thread safe and 'static, so that the `Report`
|
||||||
|
/// will be as well.
|
||||||
|
///
|
||||||
|
/// Boxed `Diagnostic`s don't implement `Diagnostic` themselves due to trait coherence issues.
|
||||||
|
/// This method allows you to create a `Report` from a boxed `Diagnostic`.
|
||||||
|
#[cfg_attr(track_caller, track_caller)]
|
||||||
|
pub fn new_boxed(error: Box<dyn Diagnostic + Send + Sync + 'static>) -> Self {
|
||||||
|
Report::from_boxed(error)
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg_attr(track_caller, track_caller)]
|
#[cfg_attr(track_caller, track_caller)]
|
||||||
pub(crate) fn from_std<E>(error: E) -> Self
|
pub(crate) fn from_std<E>(error: E) -> Self
|
||||||
where
|
where
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue