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§