Skip to main content

Error

Struct Error 

Source
pub struct Error<Kind, Context> { /* private fields */ }
Expand description

An error that has a Kind and optional list of Context instances.

The Kind represents the original root cause of the error, whereas the Context type provides additional information.

Implementations§

Source§

impl<Kind, Context> Error<Kind, Context>

Source

pub fn new<T: Into<Kind>>(kind: T) -> Error<Kind, Context>

Creates a new Error of the desired kind. The created error contains no additional context information.

Source

pub fn context<T: Into<Context>>(self, ctx: T) -> Self

Adds context to the error.

Source§

impl<K, T> Error<ErrorKind<K, T>, Context>

Source

pub fn end_of_stream() -> ParseError<K, T>

Creates a new ParseError with the kind ErrorKind::EndOfStream.

Source

pub fn unexpected(span: Span, got: T, expected: String) -> ParseError<K, T>

Creates a new ParseError with the kind ErrorKind::UnexpectedToken.

Source

pub fn other(span: Span, kind: K) -> ParseError<K, T>

Creates a new ParseError from an parser of format specific error type. The returned parse error will have a kind of ErrorKind::Other, with the kind set to the provided value.

Source

pub fn span(&self) -> Option<&Span>

Returns the location of the error relative to the start of the input stream if known.

Trait Implementations§

Source§

impl<Kind: Clone, Context: Clone> Clone for Error<Kind, Context>

Source§

fn clone(&self) -> Error<Kind, Context>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Kind: Debug, Context: Debug> Debug for Error<Kind, Context>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Kind, Context> Display for Error<Kind, Context>
where Kind: Display, Context: ErrorContext,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Kind, Context> Freeze for Error<Kind, Context>
where Kind: Freeze,

§

impl<Kind, Context> RefUnwindSafe for Error<Kind, Context>
where Kind: RefUnwindSafe, Context: RefUnwindSafe,

§

impl<Kind, Context> Send for Error<Kind, Context>
where Kind: Send, Context: Send,

§

impl<Kind, Context> Sync for Error<Kind, Context>
where Kind: Sync, Context: Sync,

§

impl<Kind, Context> Unpin for Error<Kind, Context>
where Kind: Unpin, Context: Unpin,

§

impl<Kind, Context> UnsafeUnpin for Error<Kind, Context>
where Kind: UnsafeUnpin,

§

impl<Kind, Context> UnwindSafe for Error<Kind, Context>
where Kind: UnwindSafe, Context: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> SendSyncUnwindSafe for T
where T: Send + Sync + UnwindSafe + ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.