pub enum ExecutionError {
Show 19 variants
StackUnderflow,
StackOverflow,
TypeError(String),
RuntimeError(String),
MemoryError(String),
InvalidInstruction(String),
FunctionError(String),
VariableError(String),
HeapError(String),
ControlFlowError(String),
BuiltinError(String),
DivisionByZero,
InvalidIndex(usize),
PropertyNotFound(String),
MethodNotFound(String),
InvalidArgumentCount {
expected: usize,
received: usize,
},
RecursionLimitExceeded(usize),
ExecutionTimeout,
UnsupportedOperation(String),
}Expand description
Represents all possible errors that can occur during VM execution
This enum provides a comprehensive set of error types covering all aspects of virtual machine operation.
Variants§
StackUnderflow
Stack is empty when trying to pop a value
StackOverflow
Stack is full when trying to push a value
TypeError(String)
Invalid type conversion or operation
RuntimeError(String)
General runtime execution error
MemoryError(String)
Invalid memory access or allocation failure
InvalidInstruction(String)
Invalid instruction or bytecode
FunctionError(String)
Function call or return error
VariableError(String)
Variable access or assignment error
HeapError(String)
Heap allocation or garbage collection error
ControlFlowError(String)
Control flow error (invalid jumps, etc.)
BuiltinError(String)
Built-in function error
DivisionByZero
Division by zero
InvalidIndex(usize)
Invalid array index
PropertyNotFound(String)
Property not found on object
MethodNotFound(String)
Method not found on object
InvalidArgumentCount
Invalid argument count for function call
RecursionLimitExceeded(usize)
Recursion limit exceeded
ExecutionTimeout
Timeout during execution
UnsupportedOperation(String)
Unsupported operation
Implementations§
Source§impl ExecutionError
impl ExecutionError
Sourcepub fn new_type_error(message: impl Into<String>) -> Self
pub fn new_type_error(message: impl Into<String>) -> Self
Sourcepub fn new_runtime_error(message: impl Into<String>) -> Self
pub fn new_runtime_error(message: impl Into<String>) -> Self
Sourcepub fn new_memory_error(message: impl Into<String>) -> Self
pub fn new_memory_error(message: impl Into<String>) -> Self
Sourcepub fn new_function_error(message: impl Into<String>) -> Self
pub fn new_function_error(message: impl Into<String>) -> Self
Sourcepub fn new_variable_error(message: impl Into<String>) -> Self
pub fn new_variable_error(message: impl Into<String>) -> Self
Sourcepub fn new_heap_error(message: impl Into<String>) -> Self
pub fn new_heap_error(message: impl Into<String>) -> Self
Sourcepub fn new_control_flow_error(message: impl Into<String>) -> Self
pub fn new_control_flow_error(message: impl Into<String>) -> Self
Sourcepub fn new_builtin_error(message: impl Into<String>) -> Self
pub fn new_builtin_error(message: impl Into<String>) -> Self
Sourcepub fn new_unsupported_operation(message: impl Into<String>) -> Self
pub fn new_unsupported_operation(message: impl Into<String>) -> Self
Creates a new unsupported operation error with the given message
§Arguments
message- The error message
§Returns
- A new
ExecutionError::UnsupportedOperation
§Examples
let error = ExecutionError::new_unsupported_operation("BigInt operations");
assert!(matches!(error, ExecutionError::UnsupportedOperation(_)));Sourcepub fn is_recoverable(&self) -> bool
pub fn is_recoverable(&self) -> bool
Checks if this error is recoverable
Some errors can be recovered from automatically, while others require manual intervention or indicate a serious problem.
§Returns
trueif the error is recoverablefalseif the error requires manual intervention
§Examples
let stack_error = ExecutionError::StackUnderflow;
assert!(stack_error.is_recoverable());
let type_error = ExecutionError::TypeError("Invalid operation".to_string());
assert!(!type_error.is_recoverable());Sourcepub fn is_fatal(&self) -> bool
pub fn is_fatal(&self) -> bool
Checks if this error is fatal
Fatal errors cannot be recovered from and typically indicate a serious problem with the program or VM state.
§Returns
trueif the error is fatalfalseif the error is not fatal
§Examples
let memory_error = ExecutionError::MemoryError("Heap corruption".to_string());
assert!(memory_error.is_fatal());
let stack_error = ExecutionError::StackUnderflow;
assert!(!stack_error.is_fatal());Sourcepub fn get_user_message(&self) -> String
pub fn get_user_message(&self) -> String
Gets a user-friendly error message
Returns a formatted error message suitable for display to users.
§Returns
- A formatted error message string
§Examples
let error = ExecutionError::TypeError("Cannot add string and number".to_string());
let message = error.get_user_message();
assert!(message.contains("Type error"));Sourcepub fn get_debug_message(&self) -> String
pub fn get_debug_message(&self) -> String
Gets a debug error message
Returns a detailed error message suitable for debugging and development.
§Returns
- A detailed debug message string
§Examples
let error = ExecutionError::TypeError("Cannot add string and number".to_string());
let debug_msg = error.get_debug_message();
assert!(debug_msg.contains("TypeError"));Trait Implementations§
Source§impl Clone for ExecutionError
impl Clone for ExecutionError
Source§fn clone(&self) -> ExecutionError
fn clone(&self) -> ExecutionError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more