#[no_mangle]
pub unsafe extern "C" fn wasmer_last_error_message(
    buffer: Option<NonNull<c_char>>,
    length: c_int
) -> c_int
Expand description

Gets the last error message if any into the provided buffer buffer up to the given length.

The length parameter must be large enough to store the last error message. Ideally, the value should come from wasmer_last_error_length.

The function returns the length of the string in bytes, -1 if an error occurs. Potential errors are:

  • The buffer is a null pointer,
  • The buffer is too small to hold the error message.

Note: The error message always has a trailing NUL character.

Important note: If the provided buffer is non-null, once this function has been called, regardless whether it fails or succeeds, the error is cleared.

Example

See this module’s documentation to get a complete example.