Module error_handler

Source
Expand description

§Execution Error Handler

Defines all error types that can occur during VM execution and provides comprehensive error handling capabilities.

§Error Categories

  • Stack Errors: Underflow, overflow, invalid operations
  • Type Errors: Invalid type conversions, unsupported operations
  • Runtime Errors: General execution failures, exceptions
  • Memory Errors: Heap allocation failures, invalid references
  • Control Flow Errors: Invalid jumps, function call failures

§Error Handling Strategy

The VM uses a comprehensive error handling strategy:

  1. Immediate Detection: Errors are detected as soon as they occur
  2. Detailed Information: Each error contains context about what went wrong
  3. Recovery Options: Some errors can be recovered from automatically
  4. User Feedback: Clear error messages for debugging

§Usage

use jetcrab::vm::executor::error_handler::ExecutionError;

match some_operation() {
    Ok(result) => println!("Success: {:?}", result),
    Err(ExecutionError::StackUnderflow) => {
        eprintln!("Stack underflow occurred");
    }
    Err(ExecutionError::TypeError(msg)) => {
        eprintln!("Type error: {}", msg);
    }
    Err(e) => eprintln!("Other error: {:?}", e),
}

Enums§

ExecutionError
Represents all possible errors that can occur during VM execution