[][src]Struct lisbeth_error::error::AnnotatedError

pub struct AnnotatedError { /* fields omitted */ }

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]

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]

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]

impl Debug for AnnotatedError[src]

impl PartialEq<AnnotatedError> for AnnotatedError[src]

impl StructuralPartialEq for AnnotatedError[src]

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.