ChiselError

Struct ChiselError 

Source
pub struct ChiselError<F, S> {
    pub offset: usize,
    pub error: ChiselErrorData<F, S>,
}
Expand description

The error type for chiseling operations.

This type provides offset information alongside the error data itself to allow for more precise diagnostics.

§Kinds

This crate distinguishes between 3 ‘kinds’ of errors:

  • EndOfInput: An unexpected end-of-input condition. If chiseling is retried with additional data provided in the input, it may succeed.
  • Source: The Chisel’s source signalled an error condition.
  • Format: The provided data to chisel is invalid in some way.

Fields§

§offset: usize

The byte offset that the error occurred at.

This is the offset of the beginning of the erroring operation or item.

§error: ChiselErrorData<F, S>

The error data itself.

Implementations§

Source§

impl<F, S> ChiselError<F, S>

Source

pub fn new(offset: usize, error: ChiselErrorData<F, S>) -> Self

Creates a new Chisel Error with the provided offset and error data.

Source

pub fn end_of_input(offset: usize) -> Self

Creates a new “unexpected end-of-input” Chisel Error with the provided offset.

Source

pub fn source(offset: usize, error: S) -> Self

Creates a new Chisel Source Error with the provided offset and ‘underlying’ error.

Source

pub fn format(offset: usize, error: F) -> Self

Creates a new Chisel Format Error with the provided offset and detail.

Source

pub fn map<M: FnOnce(F) -> N, N>(self, mapper: M) -> ChiselError<N, S>

Maps a ChiselError<F, S> to ChiselError<N, S> by applying a function to the contained format error, if any.

This can be used to provide additional information about the issue with the provided data.

Note that both EndOfInput and Source errors are returned untouched.

Source§

impl<S> ChiselError<Infallible, S>

Source

pub fn from_source(offset: usize, error: ChiselSourceError<S>) -> Self

Creates a ChiselError from a ChiselSourceError + an offset.

Source

pub fn forward<F>(self) -> ChiselError<F, S>

Convert an InfallibleFormatError into an error with arbitrary format type.

(Note that because Infallible is uninhabited, this is always valid.)

This is basically a small hack to allow easy error propagation, as ChiselError<F, S> cannot implement From<ChiselError<Infallible, S>>.

Trait Implementations§

Source§

impl<F: Debug, S: Debug> Debug for ChiselError<F, S>

Source§

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

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

impl<F: Display, S: Display> Display for ChiselError<F, S>

Source§

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

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

impl<F: Error + 'static, S: Error + 'static> Error for ChiselError<F, S>

Source§

fn cause(&self) -> Option<&(dyn Error + 'static)>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more

Auto Trait Implementations§

§

impl<F, S> Freeze for ChiselError<F, S>
where F: Freeze, S: Freeze,

§

impl<F, S> RefUnwindSafe for ChiselError<F, S>

§

impl<F, S> Send for ChiselError<F, S>
where F: Send, S: Send,

§

impl<F, S> Sync for ChiselError<F, S>
where F: Sync, S: Sync,

§

impl<F, S> Unpin for ChiselError<F, S>
where F: Unpin, S: Unpin,

§

impl<F, S> UnwindSafe for ChiselError<F, S>
where F: UnwindSafe, S: 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> 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> 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.