if _rc != 0 {
    let msg = if _out_error.is_null() {
        format!("vtable.{{ name }} returned error code {}", _rc)
    } else {
        // SAFETY: out_error was written by the callee as a valid NUL-terminated string.
        let msg = unsafe { std::ffi::CStr::from_ptr(_out_error) }.to_string_lossy().into_owned();
        if let Some(free_fn) = {{ vtable_expr }}.free_string {
            // SAFETY: free_fn is the vtable-provided destructor for callback strings.
            unsafe { free_fn(_out_error) };
        }
        msg
    };
    {{ error_return }}
}
