pub enum Fault {
DivideByZero,
RegisterOutOfRange {
reg: u8,
frame_size: u8,
},
BadConstant {
index: u32,
pool_size: u32,
},
BadFunction {
index: u32,
table_size: u32,
},
BadOpcodeByte(u8),
CallStackOverflow {
depth: usize,
},
TypeMismatch {
expected: &'static str,
got: &'static str,
},
BadNative {
index: u32,
table_size: u32,
},
NativeError(String),
Explicit(i32),
Invariant(&'static str),
}Expand description
Anything that can go wrong inside a running Flow’s VM.
A Fault is never a Rust panic — panics are reserved for genuine host
bugs and are caught at the worker boundary (see
byteflow-scheduler::worker::run_worker) precisely so that one Flow’s
bug (division by zero, a corrupt jump target that slipped past the
verifier, an out-of-range register) can never take down a worker thread,
let alone the whole runtime. A Fault instead becomes
FlowState::Failed and is handed to the Flow’s supervisor, which
decides whether to restart it (design notes §15-16).
Variants§
DivideByZero
RegisterOutOfRange
BadConstant
BadFunction
BadOpcodeByte(u8)
CallStackOverflow
Function call nesting exceeded Vm::MAX_CALL_DEPTH. Bytecode has no
native stack overflow (frames are heap-allocated Vec<Value>s), so
this is a deliberate, checked limit rather than a segfault.
TypeMismatch
BadNative
CallNative referenced a slot outside the runtime’s registered
native function table (design notes §30-31). Distinct from
BadFunction, which is about the bytecode function table baked
into the chunk — natives are supplied by the embedder at Vm
construction time and can’t be range-checked by
crate::bytecode::verify, which has no visibility into them.
NativeError(String)
A native function returned an error (host-side failure — I/O, invalid argument the Rust side rejected, capability denied, etc). The message is native-function-defined.
Explicit(i32)
Explicit Trap opcode, e.g. an assertion emitted by a compiler.
Invariant(&'static str)
Broken VM invariant (e.g. empty frame stack while running). Category D
in the error model — surfaced as a Flow fault, never as unwrap.
Trait Implementations§
Source§impl Error for Fault
impl Error for Fault
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()