[−][src]Struct lisbeth_error::error::AnnotatedError
An error report with annotations.
This error report is created with the precise span at which the error occurs and a simple message explaining the situation. It can then be improved by adding more information.
Example
The following code shows how to create a simple error report.
use lisbeth_error::{ error::AnnotatedError, span::{Span, SpannedStr}, }; let file = SpannedStr::input_file("The cat are on the table."); let cat = file.split_at(4).1.split_at(3).0; let are = file.split_at(8).1.split_at(3).0; let report = AnnotatedError::new(are.span(), "Conjugation error") .with_annotation(cat.span(), "`cat` is singular,") .with_annotation(are.span(), "but `are` is used only for plural subject");
Implementations
impl AnnotatedError
[src]
pub fn new<Msg>(span: Span, msg: Msg) -> AnnotatedError where
Msg: ToString,
[src]
Msg: ToString,
Constructs a new report.
span
represents the precise location at which the error is
encountered, msg
describes the issue. msg
can be either a static
string slice or a String
.
pub fn with_annotation<Msg>(self, span: Span, msg: Msg) -> AnnotatedError where
Msg: ToString,
[src]
Msg: ToString,
Adds a new annotation at a given span to the report.
pub fn span(&self) -> Span
[src]
Returns the span at which the error is encountered.
Trait Implementations
impl Clone for AnnotatedError
[src]
pub fn clone(&self) -> AnnotatedError
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for AnnotatedError
[src]
impl PartialEq<AnnotatedError> for AnnotatedError
[src]
pub fn eq(&self, other: &AnnotatedError) -> bool
[src]
pub fn ne(&self, other: &AnnotatedError) -> bool
[src]
impl StructuralPartialEq for AnnotatedError
[src]
Auto Trait Implementations
impl RefUnwindSafe for AnnotatedError
[src]
impl Send for AnnotatedError
[src]
impl Sync for AnnotatedError
[src]
impl Unpin for AnnotatedError
[src]
impl UnwindSafe for AnnotatedError
[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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
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>,