tfe_last_error_message

Function tfe_last_error_message 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn tfe_last_error_message( buf: *mut u8, buf_len: usize, out_len: *mut usize, ) -> tfe_status_t
Expand description

Retrieve the last error message (UTF-8, null-terminated).

  • buf == NULL: query required length only (written to *out_len).
  • buf != NULL: copy message into buffer.

out_len receives the required buffer size including the null terminator.

§Returns

  • TFE_SUCCESS on success (or query-only mode).
  • TFE_INVALID_ARGUMENT if out_len is null.
  • TFE_BUFFER_TOO_SMALL if buf_len is too small (required size in *out_len).

§Safety

  • out_len must be a valid, non-null pointer.
  • If buf is non-null, it must point to a buffer of at least buf_len bytes.

§Examples (C)

size_t len;
tfe_last_error_message(NULL, 0, &len);
if (len > 0) {
    char *buf = malloc(len);
    tfe_last_error_message((uint8_t *)buf, len, &len);
    printf("Error: %s\n", buf);
    free(buf);
}