relay_ffi

Function take_last_error

source
pub fn take_last_error() -> Option<Error>
Expand description

Takes the last error, leaving None in its place.

To inspect the error without removing it, use with_last_error.

ยงExample

use relay_ffi::{catch_unwind, take_last_error};

#[catch_unwind]
unsafe fn run_ffi() -> i32 {
    "invalid".parse()?
}

let parsed = unsafe { run_ffi() };
match take_last_error() {
    Some(error) => println!("errored with: {error}"),
    None => println!("result: {parsed}"),
}