Trait miette::Diagnostic
source · [−]pub trait Diagnostic: Error {
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
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.
Diagnostic severity. This may be used by
ReportHandler
s to change the display format
of this diagnostic.
If None
, reporters should treat this as Severity::Error
.
Additional help text related to this Diagnostic
. Do you have any
advice for the poor soul who’s just run into this issue?
URL to visit for a more detailed explanation/help about this
Diagnostic
.
sourcefn source_code(&self) -> Option<&dyn SourceCode>
fn source_code(&self) -> Option<&dyn SourceCode>
Source code to apply this Diagnostic
’s Diagnostic::labels
to.
Labels to apply to this Diagnostic
’s Diagnostic::source_code
Additional related Diagnostic
s.
sourcefn diagnostic_source(&self) -> Option<&dyn Diagnostic>
fn diagnostic_source(&self) -> Option<&dyn Diagnostic>
The cause of the error.
Trait Implementations
sourceimpl AsRef<dyn Diagnostic + 'static> for Report
impl AsRef<dyn Diagnostic + 'static> for Report
sourcefn as_ref(&self) -> &(dyn Diagnostic + 'static)
fn as_ref(&self) -> &(dyn Diagnostic + 'static)
sourceimpl AsRef<dyn Diagnostic + Send + Sync + 'static> for Report
impl AsRef<dyn Diagnostic + Send + Sync + 'static> for Report
sourcefn as_ref(&self) -> &(dyn Diagnostic + Send + Sync + 'static)
fn as_ref(&self) -> &(dyn Diagnostic + Send + Sync + 'static)
sourceimpl Borrow<dyn Diagnostic + 'static> for Report
impl Borrow<dyn Diagnostic + 'static> for Report
sourcefn borrow(&self) -> &(dyn Diagnostic + 'static)
fn borrow(&self) -> &(dyn Diagnostic + 'static)
sourceimpl Error for Box<dyn Diagnostic>
impl Error for Box<dyn Diagnostic>
sourcefn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
sourcefn cause(&self) -> Option<&dyn Error>
fn cause(&self) -> Option<&dyn Error>
replaced by Error::source, which can support downcasting
1.0.0 · sourcefn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()