pub trait ErrorType: Error {
type Span: Span + Default;
type Message: Display;
// Required methods
fn kind(&self) -> Kind;
fn number(&self) -> &str;
fn code(&self) -> &str;
fn primary_span(&self) -> Option<Self::Span>;
fn primary_message(&self) -> Self::Message;
fn primary_label(&self) -> Self::Message;
fn additional(
&self,
) -> Box<dyn Iterator<Item = (Option<Self::Span>, Self::Message, Self::Message)>>;
// Provided method
fn primary(&self) -> (Option<Self::Span>, Self::Message, Self::Message) { ... }
}Expand description
Trait for error types generated by error_type! macro and ErrorType derive macro.
For conversion to other diagnostic types, see ErrorTypeExt.
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) -> Option<Self::Span>
fn primary_span(&self) -> Option<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.