#[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
FuelExhausted
The instruction fuel budget was exhausted. Script pcall cannot catch it.
RecursionLimit
Nested script calls reached the configured depth. Script pcall cannot catch it.
RegisterOutOfBounds
Bytecode referred to a register outside its register file.
Fields
ConstantOutOfBounds
Bytecode referred to a constant outside its constant pool.
Fields
TypeError
An operation received a value of an incompatible type.
OutOfMemory
A guest allocation failed or exceeded the VM’s logical memory quota. This does not identify an operating-system memory limit.
A typed callback was called without an invocation for its host schema.
HostResourceExhausted
A bounded host-invocation resource was exhausted.
Fields
HostPanicked
A host callback’s unwinding panic was contained and the VM was poisoned. Reset the decision before executing more guest code.
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
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.
RuntimeError
An ordinary script operation failed with a textual message.
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.
Unsupported
Execution requested a feature that the engine does not implement.
CapabilityRemoved
The selected profile does not permit a requested capability.
Fields
HardenedLeafViolation
The hardened-leaf environment does not permit a requested operation or setting.
GuestEnvironmentSealed
An operation tried to change the sealed hardened-leaf guest environment.
InvalidProgram
A bytecode or program-state invariant was invalid.
Trait Implementations§
Source§impl Clone for VmErrorKind
impl Clone for VmErrorKind
Source§fn clone(&self) -> VmErrorKind
fn clone(&self) -> VmErrorKind
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more