mirror of https://github.com/zkat/miette.git
fix(context): pass on diagnostic metadata when wrapping with `Report`
This commit is contained in:
parent
0ba3358443
commit
e4fdac38ea
|
|
@ -125,9 +125,55 @@ where
|
|||
D: Display,
|
||||
E: Diagnostic + 'static,
|
||||
{
|
||||
fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>> {
|
||||
self.error.code()
|
||||
}
|
||||
|
||||
fn severity(&self) -> Option<crate::Severity> {
|
||||
self.error.severity()
|
||||
}
|
||||
|
||||
fn help<'a>(&'a self) -> Option<Box<dyn Display + 'a>> {
|
||||
self.error.help()
|
||||
}
|
||||
|
||||
fn url<'a>(&'a self) -> Option<Box<dyn Display + 'a>> {
|
||||
self.error.url()
|
||||
}
|
||||
|
||||
fn snippets<'a>(
|
||||
&'a self,
|
||||
) -> Option<Box<dyn Iterator<Item = crate::DiagnosticSnippet<'a>> + 'a>> {
|
||||
self.error.snippets()
|
||||
}
|
||||
}
|
||||
|
||||
impl<D> Diagnostic for ContextError<D, Report> where D: Display {}
|
||||
impl<D> Diagnostic for ContextError<D, Report>
|
||||
where
|
||||
D: Display,
|
||||
{
|
||||
fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>> {
|
||||
self.error.inner.diagnostic().code()
|
||||
}
|
||||
|
||||
fn severity(&self) -> Option<crate::Severity> {
|
||||
self.error.inner.diagnostic().severity()
|
||||
}
|
||||
|
||||
fn help<'a>(&'a self) -> Option<Box<dyn Display + 'a>> {
|
||||
self.error.inner.diagnostic().help()
|
||||
}
|
||||
|
||||
fn url<'a>(&'a self) -> Option<Box<dyn Display + 'a>> {
|
||||
self.error.inner.diagnostic().url()
|
||||
}
|
||||
|
||||
fn snippets<'a>(
|
||||
&'a self,
|
||||
) -> Option<Box<dyn Iterator<Item = crate::DiagnosticSnippet<'a>> + 'a>> {
|
||||
self.error.inner.diagnostic().snippets()
|
||||
}
|
||||
}
|
||||
|
||||
struct Quoted<D>(D);
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ use std::error::Error as StdError;
|
|||
|
||||
use crate::Diagnostic;
|
||||
|
||||
use crate as miette;
|
||||
|
||||
#[repr(transparent)]
|
||||
pub(crate) struct DisplayError<M>(pub(crate) M);
|
||||
|
||||
|
|
@ -69,7 +71,9 @@ impl Display for NoneError {
|
|||
impl StdError for NoneError {}
|
||||
impl Diagnostic for NoneError {}
|
||||
|
||||
#[derive(miette_derive::Diagnostic)]
|
||||
#[repr(transparent)]
|
||||
#[diagnostic(transparent)]
|
||||
pub(crate) struct BoxedError(pub(crate) Box<dyn Diagnostic + Send + Sync>);
|
||||
|
||||
impl Debug for BoxedError {
|
||||
|
|
@ -85,4 +89,3 @@ impl Display for BoxedError {
|
|||
}
|
||||
|
||||
impl StdError for BoxedError {}
|
||||
impl Diagnostic for BoxedError {}
|
||||
|
|
|
|||
Loading…
Reference in New Issue