Enum rhai::EvalAltResult

source ·
#[non_exhaustive]
pub enum EvalAltResult {
Show 33 variants ErrorSystem(String, Box<dyn Error>), ErrorParsing(ParseErrorType, Position), ErrorVariableExists(String, Position), ErrorForbiddenVariable(String, Position), ErrorVariableNotFound(String, Position), ErrorPropertyNotFound(String, Position), ErrorIndexNotFound(Dynamic, Position), ErrorFunctionNotFound(String, Position), ErrorModuleNotFound(String, Position), ErrorInFunctionCall(String, String, Box<Self>, Position), ErrorInModule(String, Box<Self>, Position), ErrorUnboundThis(Position), ErrorMismatchDataType(String, String, Position), ErrorMismatchOutputType(String, String, Position), ErrorIndexingType(String, Position), ErrorArrayBounds(usize, INT, Position), ErrorStringBounds(usize, INT, Position), ErrorBitFieldBounds(usize, INT, Position), ErrorFor(Position), ErrorDataRace(String, Position), ErrorNonPureMethodCallOnConstant(String, Position), ErrorAssignmentToConstant(String, Position), ErrorDotExpr(String, Position), ErrorArithmetic(String, Position), ErrorTooManyOperations(Position), ErrorTooManyModules(Position), ErrorStackOverflow(Position), ErrorDataTooLarge(String, Position), ErrorTerminated(Dynamic, Position), ErrorCustomSyntax(String, Vec<String>, Position), ErrorRuntime(Dynamic, Position), LoopBreak(bool, Dynamic, Position), Return(Dynamic, Position),
}
Expand description

Evaluation result.

All wrapped Position values represent the location in the script where the error occurs.

Some errors never appear when certain features are turned on. They still exist so that the application can turn features on and off without going through massive code changes to remove/add back enum variants in match statements.

Thread Safety

Currently, EvalAltResult is neither Send nor Sync. Turn on the sync feature to make it Send + Sync.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

ErrorSystem(String, Box<dyn Error>)

System error. Wrapped values are the error message and the internal error.

§

ErrorParsing(ParseErrorType, Position)

Syntax error.

§

ErrorVariableExists(String, Position)

Shadowing of an existing variable disallowed. Wrapped value is the variable name.

§

ErrorForbiddenVariable(String, Position)

Forbidden variable name. Wrapped value is the variable name.

§

ErrorVariableNotFound(String, Position)

Access of an unknown variable. Wrapped value is the variable name.

§

ErrorPropertyNotFound(String, Position)

Access of an unknown object map property. Wrapped value is the property name.

§

ErrorIndexNotFound(Dynamic, Position)

Access of an invalid index. Wrapped value is the index name.

§

ErrorFunctionNotFound(String, Position)

Call to an unknown function. Wrapped value is the function signature.

§

ErrorModuleNotFound(String, Position)

Usage of an unknown module. Wrapped value is the module name.

§

ErrorInFunctionCall(String, String, Box<Self>, Position)

An error has occurred inside a called function. Wrapped values are the function name, function source, and the interior error.

§

ErrorInModule(String, Box<Self>, Position)

An error has occurred while loading a module. Wrapped value are the module name and the interior error.

§

ErrorUnboundThis(Position)

Access to this that is not bound.

§

ErrorMismatchDataType(String, String, Position)

Data is not of the required type. Wrapped values are the type requested and type of the actual result.

§

ErrorMismatchOutputType(String, String, Position)

Returned type is not the same as the required output type. Wrapped values are the type requested and type of the actual result.

§

ErrorIndexingType(String, Position)

Trying to index into a type that has no indexer function defined. Wrapped value is the type name.

§

ErrorArrayBounds(usize, INT, Position)

Array access out-of-bounds. Wrapped values are the current number of elements in the array and the index number.

§

ErrorStringBounds(usize, INT, Position)

String indexing out-of-bounds. Wrapped values are the current number of characters in the string and the index number.

§

ErrorBitFieldBounds(usize, INT, Position)

Bit-field indexing out-of-bounds. Wrapped values are the current number of bits in the bit-field and the index number.

§

ErrorFor(Position)

The for statement encounters a type that is not iterable.

§

ErrorDataRace(String, Position)

Data race detected when accessing a variable. Wrapped value is the variable name.

§

ErrorNonPureMethodCallOnConstant(String, Position)

Calling a non-pure method on a constant. Wrapped value is the function name.

§

ErrorAssignmentToConstant(String, Position)

Assignment to a constant variable. Wrapped value is the variable name.

§

ErrorDotExpr(String, Position)

Inappropriate property access. Wrapped value is the property name.

§

ErrorArithmetic(String, Position)

Arithmetic error encountered. Wrapped value is the error message.

§

ErrorTooManyOperations(Position)

Number of operations over maximum limit.

§

ErrorTooManyModules(Position)

Modules over maximum limit.

§

ErrorStackOverflow(Position)

Call stack over maximum limit.

§

ErrorDataTooLarge(String, Position)

Data value over maximum size limit. Wrapped value is the type name.

§

ErrorTerminated(Dynamic, Position)

The script is prematurely terminated. Wrapped value is the termination token.

§

ErrorCustomSyntax(String, Vec<String>, Position)

Error encountered for a custom syntax. Wrapped values are the error message and custom syntax symbols stream.

Normally this should never happen, unless an AST is compiled on one Engine but evaluated on another unrelated Engine.

§

ErrorRuntime(Dynamic, Position)

Run-time error encountered. Wrapped value is the error token.

§

LoopBreak(bool, Dynamic, Position)

Breaking out of loops - not an error if within a loop. The wrapped value, if true, means breaking clean out of the loop (i.e. a break statement). The wrapped value, if false, means breaking the current context (i.e. a continue statement).

§

Return(Dynamic, Position)

Not an error: Value returned from a script via the return keyword. Wrapped value is the result value.

Implementations§

source§

impl EvalAltResult

source

pub const fn is_pseudo_error(&self) -> bool

Is this a pseudo error? A pseudo error is one that does not occur naturally.

LoopBreak and Return are pseudo errors.

source

pub const fn is_catchable(&self) -> bool

Can this error be caught?

source

pub const fn is_system_exception(&self) -> bool

Is this error a system exception?

source

pub fn unwrap_inner(&self) -> &Self

Unwrap this error and get the very base error.

source

pub const fn position(&self) -> Position

Get the position of this error.

source

pub fn clear_position(&mut self) -> &mut Self

Remove the position information from this error.

The position of this error is set to NONE afterwards.

source

pub fn take_position(&mut self) -> Position

Remove the position information from this error and return it.

The position of this error is set to NONE afterwards.

source

pub fn set_position(&mut self, new_position: Position) -> &mut Self

Override the position of this error.

Trait Implementations§

source§

impl Debug for EvalAltResult

source§

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

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

impl Display for EvalAltResult

source§

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

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

impl Error for Box<EvalAltResult>

source§

fn custom<T: Display>(err: T) -> Self

Raised when there is general error when deserializing a type. Read more
source§

fn invalid_type(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self

Raised when a Deserialize receives a type different from what it was expecting. Read more
source§

fn invalid_value(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self

Raised when a Deserialize receives a value of the right type but that is wrong for some other reason. Read more
source§

fn invalid_length(len: usize, exp: &dyn Expected) -> Self

Raised when deserializing a sequence or map and the input data contains too many or too few elements. Read more
source§

fn unknown_variant(variant: &str, expected: &'static [&'static str]) -> Self

Raised when a Deserialize enum type received a variant with an unrecognized name.
source§

fn unknown_field(field: &str, expected: &'static [&'static str]) -> Self

Raised when a Deserialize struct type received a field with an unrecognized name.
source§

fn missing_field(field: &'static str) -> Self

Raised when a Deserialize struct type expected to receive a required field with a particular name but that field was not present in the input.
source§

fn duplicate_field(field: &'static str) -> Self

Raised when a Deserialize struct type received more than one of the same field.
source§

impl Error for Box<EvalAltResult>

source§

fn custom<T: Display>(err: T) -> Self

Used when a Serialize implementation encounters any error while serializing a type. Read more
source§

impl Error for EvalAltResult

1.30.0 · source§

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

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, demand: &mut Demand<'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<T> From<EvalAltResult> for Result<T, Box<EvalAltResult>>

source§

fn from(err: EvalAltResult) -> Self

Converts to this type from the input type.
source§

impl From<ParseError> for Box<EvalAltResult>

source§

fn from(err: ParseError) -> Self

Converts to this type from the input type.
source§

impl From<ParseError> for EvalAltResult

source§

fn from(err: ParseError) -> Self

Converts to this type from the input type.
source§

impl From<ParseErrorType> for Box<EvalAltResult>

source§

fn from(err: ParseErrorType) -> Self

Converts to this type from the input type.
source§

impl From<ParseErrorType> for EvalAltResult

source§

fn from(err: ParseErrorType) -> Self

Converts to this type from the input type.
source§

impl<T: AsRef<str>> From<T> for Box<EvalAltResult>

source§

fn from(err: T) -> Self

Converts to this type from the input type.
source§

impl<T: AsRef<str>> From<T> for EvalAltResult

source§

fn from(err: T) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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<E> Provider for Ewhere E: Error + ?Sized,

source§

fn provide<'a>(&'a self, demand: &mut Demand<'a>)

🔬This is a nightly-only experimental API. (provide_any)
Data providers should implement this method to provide all values they are able to provide by using demand. Read more
source§

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

source§

default fn to_string(&self) -> String

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

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.