pub enum VMError {
Show 16 variants
StackUnderflow,
StackOverflow,
TypeError {
expected: &'static str,
got: &'static str,
},
DivisionByZero,
UndefinedVariable(String),
UndefinedProperty(String),
InvalidCall,
IndexOutOfBounds {
index: i32,
length: usize,
},
InvalidOperand,
ArityMismatch {
function: String,
expected: usize,
got: usize,
},
InvalidArgument {
function: String,
message: String,
},
NotImplemented(String),
RuntimeError(String),
Suspended {
future_id: u64,
resume_ip: usize,
},
Interrupted,
ResumeRequested,
}Expand description
VM runtime errors
Variants§
StackUnderflow
Stack underflow
StackOverflow
Stack overflow
TypeError
Type mismatch
DivisionByZero
Division by zero
UndefinedVariable(String)
Variable not found
UndefinedProperty(String)
Property not found
InvalidCall
Invalid function call
IndexOutOfBounds
Invalid array index
InvalidOperand
Invalid operand
ArityMismatch
Wrong number of arguments passed to a function
InvalidArgument
Invalid argument value (correct type, wrong value)
NotImplemented(String)
Feature not yet implemented
RuntimeError(String)
Runtime error with message
Suspended
VM suspended on await — not a real error, used to propagate suspension up the Rust call stack
Interrupted
Execution interrupted by Ctrl+C signal
ResumeRequested
Internal: state.resume() requested VM state restoration. Not a real error — intercepted by the dispatch loop.
Implementations§
Source§impl VMError
impl VMError
Sourcepub fn type_mismatch(expected: &'static str, got: &'static str) -> VMError
pub fn type_mismatch(expected: &'static str, got: &'static str) -> VMError
Convenience constructor for TypeError { expected, got }.
Sourcepub fn argument_count_error(
fn_name: impl Into<String>,
expected: usize,
got: usize,
) -> VMError
pub fn argument_count_error( fn_name: impl Into<String>, expected: usize, got: usize, ) -> VMError
Convenience constructor for argument-count errors.
Produces ArityMismatch { function, expected, got } with a consistent
message format: "fn_name() expects N argument(s), got M".
Prefer this over hand-writing VMError::RuntimeError(format!(...)) for
arity mismatches — it uses the structured ArityMismatch variant which
tools can match on programmatically.
Sourcepub fn type_error(
fn_name: &str,
expected_type: &str,
got_value: &str,
) -> VMError
pub fn type_error( fn_name: &str, expected_type: &str, got_value: &str, ) -> VMError
Convenience constructor for type errors in builtin/stdlib functions.
Produces a RuntimeError with the format:
"fn_name(): expected <expected_type>, got <got_value>".
Use this when a function receives a value of the wrong type. For the
lower-level TypeError { expected, got } variant (which requires
&'static str), use VMError::type_mismatch() instead.
Trait Implementations§
Source§impl Error for VMError
impl Error for VMError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<ShapeError> for VMError
impl From<ShapeError> for VMError
Source§fn from(err: ShapeError) -> VMError
fn from(err: ShapeError) -> VMError
impl StructuralPartialEq for VMError
Auto Trait Implementations§
impl Freeze for VMError
impl RefUnwindSafe for VMError
impl Send for VMError
impl Sync for VMError
impl Unpin for VMError
impl UnsafeUnpin for VMError
impl UnwindSafe for VMError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.