TireaError

Enum TireaError 

Source
pub enum TireaError {
    PathNotFound {
        path: Path,
    },
    IndexOutOfBounds {
        path: Path,
        index: usize,
        len: usize,
    },
    TypeMismatch {
        path: Path,
        expected: &'static str,
        found: &'static str,
    },
    NumericOperationOnNonNumber {
        path: Path,
    },
    MergeRequiresObject {
        path: Path,
    },
    AppendRequiresArray {
        path: Path,
    },
    InvalidOperation {
        message: String,
    },
    Serialization(Error),
}
Expand description

Errors that can occur during tirea-state operations.

Variants§

§

PathNotFound

Path does not exist in the document.

Fields

§path: Path

The path that was not found.

§

IndexOutOfBounds

Array index is out of bounds.

Fields

§path: Path

The path to the array.

§index: usize

The index that was accessed.

§len: usize

The actual length of the array.

§

TypeMismatch

Type mismatch when accessing a value.

Fields

§path: Path

The path where the mismatch occurred.

§expected: &'static str

The expected type.

§found: &'static str

The actual type found.

§

NumericOperationOnNonNumber

Numeric operation on a non-numeric value.

Fields

§path: Path

The path where the non-numeric value was found.

§

MergeRequiresObject

Merge operation requires an object value.

Fields

§path: Path

The path where a non-object was found.

§

AppendRequiresArray

Append operation requires an array value.

Fields

§path: Path

The path where a non-array was found.

§

InvalidOperation

Invalid operation error.

Fields

§message: String

Description of what went wrong.

§

Serialization(Error)

JSON serialization/deserialization error.

Implementations§

Source§

impl TireaError

Source

pub fn path_not_found(path: Path) -> Self

Create a path not found error.

Source

pub fn index_out_of_bounds(path: Path, index: usize, len: usize) -> Self

Create an index out of bounds error.

Source

pub fn type_mismatch( path: Path, expected: &'static str, found: &'static str, ) -> Self

Create a type mismatch error.

Source

pub fn numeric_on_non_number(path: Path) -> Self

Create a numeric operation on non-number error.

Source

pub fn merge_requires_object(path: Path) -> Self

Create a merge requires object error.

Source

pub fn append_requires_array(path: Path) -> Self

Create an append requires array error.

Source

pub fn invalid_operation(message: impl Into<String>) -> Self

Create an invalid operation error.

Source

pub fn with_prefix(self, prefix: &Path) -> Self

Add a path prefix to this error.

This is used when deserializing nested structures to maintain the full path context. For example, if a nested struct at path “address” has an error at “city”, this will combine them into “address.city”.

Trait Implementations§

Source§

impl Debug for TireaError

Source§

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

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

impl Display for TireaError

Source§

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

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

impl Error for TireaError

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()
1.0.0 · Source§

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

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
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
Source§

impl From<Error> for TireaError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<TireaError> for StateError

Source§

fn from(source: TireaError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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.