Skip to main content

Diagnostic

Trait Diagnostic 

pub trait Diagnostic: Error {
    // Provided methods
    fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>> { ... }
    fn severity(&self) -> Option<Severity> { ... }
    fn help<'a>(&'a self) -> Option<Box<dyn Display + 'a>> { ... }
    fn url<'a>(&'a self) -> Option<Box<dyn Display + 'a>> { ... }
    fn source_code(&self) -> Option<&dyn SourceCode> { ... }
    fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>> { ... }
    fn related<'a>(
        &'a self,
    ) -> Option<Box<dyn Iterator<Item = &'a dyn Diagnostic> + 'a>> { ... }
    fn diagnostic_source<'a>(&'a self) -> Option<&'a dyn Diagnostic> { ... }
}
Expand description

Adds rich metadata to your Error that can be used by Report to print really nice and human-friendly error messages.

Provided Methods§

fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>>

Unique diagnostic code that can be used to look up more information about this Diagnostic. Ideally also globally unique, and documented in the toplevel crate’s documentation for easy searching. Rust path format (foo::bar::baz) is recommended, but more classic codes like E0123 or enums will work just fine.

fn severity(&self) -> Option<Severity>

Diagnostic severity. This may be used by ReportHandlers to change the display format of this diagnostic.

If None, reporters should treat this as Severity::Error.

fn help<'a>(&'a self) -> Option<Box<dyn Display + 'a>>

Additional help text related to this Diagnostic. Do you have any advice for the poor soul who’s just run into this issue?

fn url<'a>(&'a self) -> Option<Box<dyn Display + 'a>>

URL to visit for a more detailed explanation/help about this Diagnostic.

fn source_code(&self) -> Option<&dyn SourceCode>

Source code to apply this Diagnostic’s Diagnostic::labels to.

fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>>

Labels to apply to this Diagnostic’s Diagnostic::source_code

fn related<'a>( &'a self, ) -> Option<Box<dyn Iterator<Item = &'a dyn Diagnostic> + 'a>>

Additional related Diagnostics.

fn diagnostic_source<'a>(&'a self) -> Option<&'a dyn Diagnostic>

The cause of the error.

Trait Implementations§

§

impl AsRef<dyn Diagnostic> for Report

§

fn as_ref(&self) -> &(dyn Diagnostic + 'static)

Converts this type into a shared reference of the (usually inferred) input type.
§

impl AsRef<dyn Diagnostic + Sync + Send> for Report

§

fn as_ref(&self) -> &(dyn Diagnostic + Sync + Send + 'static)

Converts this type into a shared reference of the (usually inferred) input type.
§

impl Borrow<dyn Diagnostic> for Report

§

fn borrow(&self) -> &(dyn Diagnostic + 'static)

Immutably borrows from an owned value. Read more

Implementors§

Source§

impl Diagnostic for RelatedError

Source§

impl Diagnostic for RelatedLabel

§

impl Diagnostic for InstallError

§

impl Diagnostic for MietteDiagnostic

§

impl Diagnostic for MietteError