From 0660d2f43c0a793b1e289b26bcca73c8733bdcff Mon Sep 17 00:00:00 2001 From: Rain Date: Mon, 24 Oct 2022 14:39:19 -0700 Subject: [PATCH] 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`. --- src/eyreish/error.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/eyreish/error.rs b/src/eyreish/error.rs index a7ed3bd9..32f1d1f9 100644 --- a/src/eyreish/error.rs +++ b/src/eyreish/error.rs @@ -73,6 +73,18 @@ impl Report { 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) -> Self { + Report::from_boxed(error) + } + #[cfg_attr(track_caller, track_caller)] pub(crate) fn from_std(error: E) -> Self where