Skip to main content

VmErrorKind

Enum VmErrorKind 

Source
#[non_exhaustive]
pub enum VmErrorKind {
Show 27 variants FuelExhausted { limit: u64, }, RecursionLimit { limit: usize, }, RegisterOutOfBounds { register: usize, max: usize, }, ConstantOutOfBounds { index: usize, len: usize, }, TypeError { expected: &'static str, }, OutOfMemory, HostDispatcherUnavailable, HostResourceExhausted { resource: &'static str, limit: u64, }, HostPanicked { function: String, }, VmPoisoned, YieldAcrossBoundary, DecisionResetWhileRunning, HostConfigurationWhileRunning, DecisionEpochExhausted, StaleRetainedValue { retained_epoch: u64, current_epoch: u64, }, RetainedValueFromDifferentVm, TableIndexNil, TableIndexNaN, InvalidKeyToNext, AssertionFailed { message: String, }, RuntimeError { message: String, }, GuestError { message: String, }, Unsupported { feature: &'static str, }, CapabilityRemoved { feature: &'static str, operation: Option<String>, profile: Profile, }, HardenedLeafViolation { feature: &'static str, }, GuestEnvironmentSealed, InvalidProgram { reason: &'static str, },
}
Expand description

The category of a runtime failure.

Include a fallback arm: future versions may add categories. Script-thrown objects are represented by their message here; their VM storage is private. Match a kind instead of parsing the displayed message.

use rustia::{Rustia, VmErrorKind};

let mut vm = Rustia::builder().fuel(1_000).build()?;
let error = vm.exec("while true do end").expect_err("the budget is finite");
assert!(matches!(
    error.as_vm_error().map(|error| error.kind()),
    Some(VmErrorKind::FuelExhausted { .. })
));
// Start a fresh decision, discarding the failed script's guest state.
vm.reset_decision()?;
assert_eq!(vm.eval::<i32>("return 42")?, 42);

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.
§

FuelExhausted

The instruction fuel budget was exhausted. Script pcall cannot catch it.

Fields

§limit: u64

The exhausted budget, in instruction-fuel units rather than time.

§

RecursionLimit

Nested script calls reached the configured depth. Script pcall cannot catch it.

Fields

§limit: usize

The configured maximum script call depth.

§

RegisterOutOfBounds

Bytecode referred to a register outside its register file.

Fields

§register: usize

The zero-based register index that was requested.

§max: usize

The number of available registers; valid indices are less than this value.

§

ConstantOutOfBounds

Bytecode referred to a constant outside its constant pool.

Fields

§index: usize

The zero-based constant index that was requested.

§len: usize

The number of available constants.

§

TypeError

An operation received a value of an incompatible type.

Fields

§expected: &'static str

A description of the value type the operation expected.

§

OutOfMemory

A guest allocation failed or exceeded the VM’s logical memory quota. This does not identify an operating-system memory limit.

§

HostDispatcherUnavailable

A typed callback was called without an invocation for its host schema.

§

HostResourceExhausted

A bounded host-invocation resource was exhausted.

Fields

§resource: &'static str

The resource name, such as a record-count or record-byte budget.

§limit: u64

The configured ceiling, in the units identified by resource.

§

HostPanicked

A host callback’s unwinding panic was contained and the VM was poisoned. Reset the decision before executing more guest code.

Fields

§function: String

The callback name reported at the host boundary.

§

VmPoisoned

Execution was rejected after an earlier host panic. crate::Rustia::reset_decision clears the poisoned state.

§

YieldAcrossBoundary

A coroutine attempted to yield across a boundary that cannot suspend.

§

DecisionResetWhileRunning

Decision reset was requested while the interpreter was executing.

§

HostConfigurationWhileRunning

A persistent host configuration change was requested during execution or a guest savepoint.

§

DecisionEpochExhausted

Decision reset could not advance the finite epoch counter.

§

StaleRetainedValue

A retained guest handle was used after its decision epoch ended.

Fields

§retained_epoch: u64

The epoch in which the handle was created.

§current_epoch: u64

The interpreter’s current epoch.

§

RetainedValueFromDifferentVm

A retained guest handle was used with a different interpreter.

§

TableIndexNil

A table write used nil as its key.

§

TableIndexNaN

A table write used NaN as its key.

§

InvalidKeyToNext

next received a key that is not valid for the supplied table.

§

AssertionFailed

A script assertion failed.

Fields

§message: String

The assertion’s message.

§

RuntimeError

An ordinary script operation failed with a textual message.

Fields

§message: String

The message without an added source-location prefix.

§

GuestError

A script raised an error value, represented here by its original text. The original guest object’s identity does not cross the facade boundary.

Fields

§message: String

The textual representation of the script’s error value.

§

Unsupported

Execution requested a feature that the engine does not implement.

Fields

§feature: &'static str

The unsupported feature’s name.

§

CapabilityRemoved

The selected profile does not permit a requested capability.

Fields

§feature: &'static str

The unavailable capability or service.

§operation: Option<String>

The specific operation, when the failure identifies one.

§profile: Profile

The profile that rejected the request.

§

HardenedLeafViolation

The hardened-leaf environment does not permit a requested operation or setting.

Fields

§feature: &'static str

The rejected operation or setting.

§

GuestEnvironmentSealed

An operation tried to change the sealed hardened-leaf guest environment.

§

InvalidProgram

A bytecode or program-state invariant was invalid.

Fields

§reason: &'static str

A description of the violated bytecode invariant.

Trait Implementations§

Source§

impl Clone for VmErrorKind

Source§

fn clone(&self) -> VmErrorKind

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for VmErrorKind

Source§

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

Formats the value using the given formatter. Read more

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> 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> 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, 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.