miette

Trait Diagnostic

source
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(&self) -> Option<&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§

source

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.

source

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.

source

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?

source

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

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

source

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

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

source

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

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

source

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

Additional related Diagnostics.

source

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

The cause of the error.

Trait Implementations§

source§

impl AsRef<dyn Diagnostic> for Report

source§

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

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

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

source§

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

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

impl Borrow<dyn Diagnostic> for Box<dyn Diagnostic + Send>

source§

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

Immutably borrows from an owned value. Read more
source§

impl Borrow<dyn Diagnostic> for Box<dyn Diagnostic + Send + Sync>

source§

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

Immutably borrows from an owned value. Read more
source§

impl Borrow<dyn Diagnostic> for Report

source§

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

Immutably borrows from an owned value. Read more
source§

impl Error for Box<dyn Diagnostic>

source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
1.0.0 · source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
source§

impl Error for Box<dyn Diagnostic + Send>

source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
1.0.0 · source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
source§

impl Error for Box<dyn Diagnostic + Send + Sync>

source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
1.0.0 · source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
source§

impl From<&str> for Box<dyn Diagnostic>

source§

fn from(s: &str) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&str> for Box<dyn Diagnostic + Send + Sync + 'a>

source§

fn from(s: &str) -> Self

Converts to this type from the input type.
source§

impl From<Box<dyn Error + Send + Sync>> for Box<dyn Diagnostic + Send + Sync>

source§

fn from(s: Box<dyn Error + Send + Sync>) -> Self

Converts to this type from the input type.
source§

impl From<Report> for Box<dyn Diagnostic + 'static>

source§

fn from(error: Report) -> Self

Converts to this type from the input type.
source§

impl From<Report> for Box<dyn Diagnostic + Send + Sync + 'static>

source§

fn from(error: Report) -> Self

Converts to this type from the input type.
source§

impl From<String> for Box<dyn Diagnostic>

source§

fn from(s: String) -> Self

Converts to this type from the input type.
source§

impl From<String> for Box<dyn Diagnostic + Send + Sync>

source§

fn from(s: String) -> Self

Converts to this type from the input type.
source§

impl<T: Diagnostic + Send + Sync + 'static> From<T> for Box<dyn Diagnostic + 'static>

source§

fn from(diag: T) -> Self

Converts to this type from the input type.
source§

impl<T: Diagnostic + Send + Sync + 'static> From<T> for Box<dyn Diagnostic + Send + 'static>

source§

fn from(diag: T) -> Self

Converts to this type from the input type.
source§

impl<T: Diagnostic + Send + Sync + 'static> From<T> for Box<dyn Diagnostic + Send + Sync + 'static>

source§

fn from(diag: T) -> Self

Converts to this type from the input type.

Implementors§