[][src]Struct lisbeth_error::reporter::ErrorReporter

pub struct ErrorReporter { /* fields omitted */ }

Holds metadata about the input, allows to report errors to the user.

This structure should be created before the parsing process and will provide metadata required for the AnnotatedError.

If the reporter contains a file path, then this path must be valid UTF-8. This is needed because the file path is printed on the console when an error is reported.

Implementations

impl ErrorReporter[src]

pub fn input_file(path: String, content: String) -> ErrorReporter[src]

Given a file path and its content, creates a new ErrorReporter.

path is not checked to be a valid path.

pub fn non_file_input(content: String) -> ErrorReporter[src]

Creates an ErrorReporter with no file path, just its content.

This can be usefull in situations in which non-file inputs such as STDIN are processed.

pub fn from_path(path: String) -> Result<ErrorReporter, IOError>[src]

Reads the content of path, and creates an ErrorReporter with it.

pub fn path(&self) -> Option<&str>[src]

Returns the file path, if it exists.

pub fn spanned_str(&self) -> SpannedStr<'_>[src]

Returns the SpannedStr associated to the whole input.

Example

use lisbeth_error::reporter::ErrorReporter;

let file = ErrorReporter::non_file_input("Hello, world".to_string());
assert_eq!(file.spanned_str().content(), "Hello, world");

pub fn format_error<'a>(&'a self, err: &'a AnnotatedError) -> FormattedError<'a>[src]

Constructs a FormattedError from an AnnotatedError.

The returned value can finally be printed to the user.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.