Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(napi): functions related to errors #17370

Merged
merged 19 commits into from
Jan 15, 2023
Merged
Prev Previous commit
Next Next commit
some lints
  • Loading branch information
bartlomieju committed Jan 13, 2023
commit 7892c7c8d4b67bd2e0ab2b5d57dad10ef11805ff
8 changes: 4 additions & 4 deletions cli/napi/js_native_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ macro_rules! return_status_if_false {
($env: expr, $condition: expr, $status: ident) => {
if !$condition {
return Err(
crate::napi::js_native_api::napi_set_last_error(
$crate::napi::js_native_api::napi_set_last_error(
$env,
$status,
0,
Expand All @@ -54,7 +54,7 @@ macro_rules! check_new_from_utf8_len {
($len == NAPI_AUTO_LENGTH) || $len <= INT_MAX as _,
napi_invalid_arg
);
return_status_if_false!($env, $str != std::ptr::null(), napi_invalid_arg);
return_status_if_false!($env, !$str.is_null(), napi_invalid_arg);
let string = if $len == NAPI_AUTO_LENGTH {
let result = std::ffi::CStr::from_ptr($str as *const _).to_str();
return_status_if_false!($env, result.is_ok(), napi_generic_failure);
Expand Down Expand Up @@ -99,13 +99,13 @@ macro_rules! status_call {
#[macro_export]
macro_rules! check_arg {
($env: expr, $ptr: expr) => {
crate::return_status_if_false!($env, !$ptr.is_null(), napi_invalid_arg);
$crate::return_status_if_false!($env, !$ptr.is_null(), napi_invalid_arg);
};
}

macro_rules! check_arg_option {
($env: expr, $opt: expr) => {
crate::return_status_if_false!($env, $opt.is_some(), napi_invalid_arg);
$crate::return_status_if_false!($env, $opt.is_some(), napi_invalid_arg);
};
}

Expand Down