Skip to main content

return_error

Function return_error 

Source
pub unsafe fn return_error(
    error: &str,
    result_buf: *mut *mut u8,
    result_len: *mut usize,
) -> i32
Expand description

Return an error result to the framework

This wraps the error message in a JSON object and returns it with an error code.

§Safety

The caller must ensure that:

  • result_buf points to valid, properly aligned memory for writing a pointer
  • result_len points to valid, properly aligned memory for writing a usize
  • These pointers remain valid for the duration of the call
  • The pointers are not aliased (no other mutable references exist)

§Example

unsafe {
    return return_error("Product not found", result_buf, result_len);
}