ErrorType

Trait ErrorType 

Source
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§

Source

type Span: Span

The span type associated with the error type.

Source

type Message: Display

The message type associated with the error type.

Required Methods§

Source

fn kind(&self) -> Kind

Get the kind of the error.

Source

fn number(&self) -> &str

Get the number of the error.

Source

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.

Source

fn primary_span(&self) -> Self::Span

Get the primary span of the error.

Source

fn primary_message(&self) -> Self::Message

Get the primary message of the error.

Source

fn primary_label(&self) -> Self::Message

Get the primary label of the error.

Provided Methods§

Source

fn fmt_as_annotate_snippets(&self) -> Result<String, Error>

Format the error as an annotate snippet.

Source

fn fmt_as_annotate_snippets_with_opts( &self, opts: FormatOptions, ) -> Result<String, Error>

Format the error as an annotate snippet with format options.

Source

fn fmt_as_ariadne_report(&self) -> Result<String, Error>

Format the error as an Ariadne report.

Source

fn fmt_as_ariadne_report_with(&self, config: Config) -> Result<String, Error>

Format the error as an Ariadne report with Ariadne config.

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.

Source

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.

Source

fn as_miette_diagnostic(&self) -> impl Diagnostic
where Self::Span: Send + Sync,

Convert the error to a Miette diagnostic.

Source

fn fmt_as_miette_diagnostic_with(&self, handler: &impl ReportHandler) -> String
where Self: Sized + 'static, Self::Span: Send + Sync,

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.

Implementations on Foreign Types§

Source§

impl<T> ErrorType for &T
where T: ErrorType + ?Sized,

Implementors§