Skip to main content

FrontendError

Trait FrontendError 

Source
pub trait FrontendError<K: Display>: Error {
    // Required methods
    fn kind(&self) -> &K;
    fn text(&self) -> &str;
    fn span(&self) -> &Span;

    // Provided methods
    fn format_error(&self, f: &mut Formatter<'_>) -> Result { ... }
    fn notate(&self) -> String { ... }
}
Expand description

A trait for representing frontend errors in the bulloak-syntax crate.

This trait is implemented by various error types in the crate to provide a consistent interface for error handling and formatting.

Required Methods§

Source

fn kind(&self) -> &K

Return the type of this error.

Source

fn text(&self) -> &str

The original text string in which this error occurred.

Source

fn span(&self) -> &Span

Return the span at which this error occurred.

Provided Methods§

Source

fn format_error(&self, f: &mut Formatter<'_>) -> Result

Formats the error message with additional context.

This method provides a default implementation that creates a formatted error message including the error kind, the relevant text, and visual indicators of where the error occurred.

§Arguments
  • f - A mutable reference to a fmt::Formatter.
§Returns

A fmt::Result indicating whether the formatting was successful.

Source

fn notate(&self) -> String

Creates a string with carets (^) pointing at the span where the error occurred.

This method provides a visual representation of where in the text the error was found.

§Returns

A String containing the relevant line of text with carets underneath.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl FrontendError<ErrorKind> for bulloak_syntax::parser::Error

Source§

impl FrontendError<ErrorKind> for bulloak_syntax::semantics::Error

Source§

impl FrontendError<ErrorKind> for bulloak_syntax::tokenizer::Error