[−][src]Struct lisbeth_error::reporter::ErrorReporter
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
impl RefUnwindSafe for ErrorReporter
[src]
impl Send for ErrorReporter
[src]
impl Sync for ErrorReporter
[src]
impl Unpin for ErrorReporter
[src]
impl UnwindSafe for ErrorReporter
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,