Skip to content

Commit

Permalink
fix(context): get labels/snippets working when using .context()
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Sep 22, 2021
1 parent 9d07dc5 commit e029657
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/eyreish/context.rs
Expand Up @@ -144,6 +144,14 @@ where
fn labels<'a>(&'a self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + 'a>> {
self.error.labels()
}

fn source_code(&self) -> Option<&dyn crate::SourceCode> {
self.error.source_code()
}

fn related<'a>(&'a self) -> Option<Box<dyn Iterator<Item = &'a dyn Diagnostic> + 'a>> {
self.error.related()
}
}

impl<D> Diagnostic for ContextError<D, Report>
Expand All @@ -169,6 +177,14 @@ where
fn labels<'a>(&'a self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + 'a>> {
self.error.inner.diagnostic().labels()
}

fn source_code(&self) -> Option<&dyn crate::SourceCode> {
self.error.source_code()
}

fn related<'a>(&'a self) -> Option<Box<dyn Iterator<Item = &'a dyn Diagnostic> + 'a>> {
self.error.related()
}
}

struct Quoted<D>(D);
Expand Down
8 changes: 8 additions & 0 deletions src/eyreish/wrapper.rs
Expand Up @@ -94,6 +94,14 @@ impl Diagnostic for BoxedError {
fn labels<'a>(&'a self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + 'a>> {
self.0.labels()
}

fn source_code(&self) -> Option<&dyn miette::SourceCode> {
self.0.source_code()
}

fn related<'a>(&'a self) -> Option<Box<dyn Iterator<Item = &'a dyn Diagnostic> + 'a>> {
self.0.related()
}
}

impl Debug for BoxedError {
Expand Down

0 comments on commit e029657

Please sign in to comment.