pub trait ErrorType: Error {
type Span: Span;
type Message: Display;
Show 14 methods
// Required methods
fn kind(&self) -> Kind;
fn number(&self) -> &str;
fn code(&self) -> &str;
fn primary_span(&self) -> Self::Span;
fn primary_message(&self) -> Self::Message;
fn primary_label(&self) -> Self::Message;
// Provided methods
fn fmt_as_annotate_snippets(&self) -> Result<String, Error> { ... }
fn fmt_as_annotate_snippets_with_opts(
&self,
opts: FormatOptions,
) -> Result<String, Error> { ... }
fn fmt_as_ariadne_report(&self) -> Result<String, Error> { ... }
fn fmt_as_ariadne_report_with(
&self,
config: Config,
) -> Result<String, Error> { ... }
fn as_codespan_diagnostic(
&self,
) -> (Diagnostic<usize>, SimpleFiles<<Self::Span as Span>::Uri, <Self::Span as Span>::Source>) { ... }
fn fmt_as_codespan_diagnostic_with(
&self,
config: Config,
styles: Option<&Styles>,
) -> Result<String, Error> { ... }
fn as_miette_diagnostic(&self) -> impl Diagnostic
where Self::Span: Send + Sync { ... }
fn fmt_as_miette_diagnostic_with(
&self,
handler: &impl ReportHandler,
) -> String
where Self: Sized + 'static,
Self::Span: Send + Sync { ... }
}Expand description
Trait for error types generated by error_type! macro and ErrorType derive macro.
Required Associated Types§
Required Methods§
Sourcefn code(&self) -> &str
fn code(&self) -> &str
Get the code of the error.
Normally the code is a combination of kind short string and number, like “E0”, “W1”, etc.
Sourcefn primary_span(&self) -> Self::Span
fn primary_span(&self) -> Self::Span
Get the primary span of the error.
Sourcefn primary_message(&self) -> Self::Message
fn primary_message(&self) -> Self::Message
Get the primary message of the error.
Sourcefn primary_label(&self) -> Self::Message
fn primary_label(&self) -> Self::Message
Get the primary label of the error.
Provided Methods§
Sourcefn fmt_as_annotate_snippets(&self) -> Result<String, Error>
fn fmt_as_annotate_snippets(&self) -> Result<String, Error>
Format the error as an annotate snippet.
Sourcefn fmt_as_annotate_snippets_with_opts(
&self,
opts: FormatOptions,
) -> Result<String, Error>
fn fmt_as_annotate_snippets_with_opts( &self, opts: FormatOptions, ) -> Result<String, Error>
Format the error as an annotate snippet with format options.
Sourcefn fmt_as_ariadne_report(&self) -> Result<String, Error>
fn fmt_as_ariadne_report(&self) -> Result<String, Error>
Format the error as an Ariadne report.
Sourcefn fmt_as_ariadne_report_with(&self, config: Config) -> Result<String, Error>
fn fmt_as_ariadne_report_with(&self, config: Config) -> Result<String, Error>
Format the error as an Ariadne report with Ariadne config.
Sourcefn as_codespan_diagnostic(
&self,
) -> (Diagnostic<usize>, SimpleFiles<<Self::Span as Span>::Uri, <Self::Span as Span>::Source>)
fn as_codespan_diagnostic( &self, ) -> (Diagnostic<usize>, SimpleFiles<<Self::Span as Span>::Uri, <Self::Span as Span>::Source>)
Format the error as an Codespan diagnostic.
Sourcefn fmt_as_codespan_diagnostic_with(
&self,
config: Config,
styles: Option<&Styles>,
) -> Result<String, Error>
fn fmt_as_codespan_diagnostic_with( &self, config: Config, styles: Option<&Styles>, ) -> Result<String, Error>
Format the error as an Codespan diagnostic with Codespan config.
Sourcefn as_miette_diagnostic(&self) -> impl Diagnostic
fn as_miette_diagnostic(&self) -> impl Diagnostic
Convert the error to a Miette diagnostic.
Sourcefn fmt_as_miette_diagnostic_with(&self, handler: &impl ReportHandler) -> String
fn fmt_as_miette_diagnostic_with(&self, handler: &impl ReportHandler) -> String
Format the error as a Miette diagnostic with a Miette handler.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.