Macro ext_php_rs::throw
source · macro_rules! throw { ($ex: expr, $reason: expr) => { ... }; }
Expand description
Throws an exception and returns from the current function.
Wraps the throw
function by inserting a return
statement after
throwing the exception.
§Examples
use ext_php_rs::{
throw,
zend::{ce, ClassEntry, ExecuteData},
types::Zval,
};
pub extern "C" fn example_fn(execute_data: &mut ExecuteData, _: &mut Zval) {
let something_wrong = true;
if something_wrong {
throw!(ce::exception(), "Something is wrong!");
}
assert!(false); // This will not run.
}