Skip to main content

run_handler

Function run_handler 

Source
pub fn run_handler<F: FnOnce() + UnwindSafe>(func: F)
Expand description

Runs the body of an extern "C" handler and keeps every Rust failure on the Rust side of the boundary.

A bailout inside func drops the BailoutGuards of this frame and is re-raised to the enclosing zend_try. A panic inside func has already unwound and run the destructors of every frame inside the handler; it is reported to PHP as an Error exception whose message starts with Rust panic: , and the handler returns normally. An exception that was already pending is kept, the panic message then only reaches the panic hook.

The handlers generated by the macros use this. Hand-written handlers passed to FunctionBuilder::new must call it themselves, since a panic escaping an extern "C" function aborts the process.