fix(napi): throw fatal error if cast return value failed (#1450)
This commit is contained in:
parent
c8352a1fb0
commit
694f761fd9
1 changed files with 13 additions and 1 deletions
|
@ -569,7 +569,19 @@ unsafe extern "C" fn call_js_cb<T: 'static, V: ToNapiValue, R, ES>(
|
||||||
value: return_value,
|
value: return_value,
|
||||||
value_type: crate::ValueType::Unknown,
|
value_type: crate::ValueType::Unknown,
|
||||||
})) {
|
})) {
|
||||||
unsafe { sys::napi_throw(raw_env, JsError::from(err).into_value(raw_env)) };
|
let message = format!(
|
||||||
|
"Failed to convert return value in ThreadsafeFunction callback into Rust value: {}",
|
||||||
|
err
|
||||||
|
);
|
||||||
|
let message_length = message.len();
|
||||||
|
unsafe {
|
||||||
|
sys::napi_fatal_error(
|
||||||
|
"threadsafe_function.rs:573\0".as_ptr().cast(),
|
||||||
|
26,
|
||||||
|
CString::new(message).unwrap().into_raw(),
|
||||||
|
message_length,
|
||||||
|
)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
status
|
status
|
||||||
|
|
Loading…
Reference in a new issue