Skip to content

Commit

Permalink
feat(report): Report::new_boxed
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
sunshowers authored and zkat committed Oct 25, 2022
1 parent 5815eab commit 0660d2f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/eyreish/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn Diagnostic + Send + Sync + 'static>) -> Self {
Report::from_boxed(error)
}

#[cfg_attr(track_caller, track_caller)]
pub(crate) fn from_std<E>(error: E) -> Self
where
Expand Down

0 comments on commit 0660d2f

Please sign in to comment.