pub struct AnnotatedError { /* private fields */ }
Expand description
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§
Source§impl AnnotatedError
impl AnnotatedError
Sourcepub fn new<Msg>(span: Span, msg: Msg) -> AnnotatedErrorwhere
Msg: ToString,
pub fn new<Msg>(span: Span, msg: Msg) -> AnnotatedErrorwhere
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
.
Sourcepub fn with_annotation<Msg>(self, span: Span, msg: Msg) -> AnnotatedErrorwhere
Msg: ToString,
pub fn with_annotation<Msg>(self, span: Span, msg: Msg) -> AnnotatedErrorwhere
Msg: ToString,
Adds a new annotation at a given span to the report.
Trait Implementations§
Source§impl Clone for AnnotatedError
impl Clone for AnnotatedError
Source§fn clone(&self) -> AnnotatedError
fn clone(&self) -> AnnotatedError
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for AnnotatedError
impl Debug for AnnotatedError
Source§impl PartialEq for AnnotatedError
impl PartialEq for AnnotatedError
impl StructuralPartialEq for AnnotatedError
Auto Trait Implementations§
impl Freeze for AnnotatedError
impl RefUnwindSafe for AnnotatedError
impl Send for AnnotatedError
impl Sync for AnnotatedError
impl Unpin for AnnotatedError
impl UnwindSafe for AnnotatedError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more