pub trait ErrorReport: Error {
    // Required methods
    fn span(self) -> Span;
    fn msg(&self) -> (String, String);

    // Provided methods
    fn report(self) -> ((String, String), Span, Option<String>)
       where Self: Sized { ... }
    fn source(&self) -> Option<String> { ... }
}
Expand description

A trait for Errors that return a specific message and span structure.

Required Methods§

source

fn span(self) -> Span

Return span information for this error.

source

fn msg(&self) -> (String, String)

Return a tuple description of the error message.

The first element is a “header” (for example: ‘Fatal Exception!’). The second element is the actual message.

Provided Methods§

source

fn report(self) -> ((String, String), Span, Option<String>)
where Self: Sized,

Return the full error report

source

fn source(&self) -> Option<String>

Return the text source for this error message.

Usually the source of the error is just the input file, in which case we return None. Sometimes, however, the source of the error may be a TokenStream or some other text. In this case, the output of source should be that stream of text.

Implementors§