fix(napi-derive-backend): wrong restrict on Result return type
This commit is contained in:
parent
ea8a79e761
commit
413a55545f
3 changed files with 8 additions and 7 deletions
|
@ -89,7 +89,7 @@ extern crate napi;
|
|||
/// import the preludes
|
||||
use napi::bindgen_prelude::*;
|
||||
|
||||
/// module registerion is done by the runtime, no need to explicitly do it now.
|
||||
/// module registration is done by the runtime, no need to explicitly do it now.
|
||||
#[napi]
|
||||
fn fibonacci(n: u32) -> u32 {
|
||||
match n {
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
"name": "test-module",
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"build": "node ../cli/scripts/index.js build --release"
|
||||
"build": "node ../cli/scripts/index.js build --js false --release"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -262,11 +262,12 @@ impl NapiFn {
|
|||
}
|
||||
} else {
|
||||
quote! {
|
||||
if #ret.is_ok() {
|
||||
<Result<#ty> as ToNapiValue>::to_napi_value(env, #ret)
|
||||
} else {
|
||||
JsError::from(#ret.unwrap_err()).throw_into(env);
|
||||
Ok(std::ptr::null_mut())
|
||||
match #ret {
|
||||
Ok(value) => ToNapiValue::to_napi_value(env, value),
|
||||
Err(err) => {
|
||||
JsError::from(err).throw_into(env);
|
||||
Ok(std::ptr::null_mut())
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue