pub fn error() -> u64 Expand description
Error codes for particular operations.
Additional Information
Normally, if the result of an ALU operation is mathematically undefined (e.g. dividing by zero), the VM Reverts.
However, if the F_UNSAFEMATH flag is set, $err is set to true and execution continues.
Returns
- [u64] - A VM error code.
Examples
use std::{registers::error, flags::{disable_panic_on_unsafe_math, enable_panic_on_unsafe_math}};
fn foo() {
disable_panic_on_unsafe_math();
let bar = 1 / 0;
assert(error() == 1);
enable_panic_on_unsafe_math();
}