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

n-api: remove unnecessary try-catch bracket from certain APIs #12705

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions src/node_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1206,14 +1206,14 @@ napi_status napi_define_properties(napi_env env,
}

napi_status napi_is_array(napi_env env, napi_value value, bool* result) {
NAPI_PREAMBLE(env);
CHECK_ENV(env);
CHECK_ARG(env, value);
CHECK_ARG(env, result);

v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value);

*result = val->IsArray();
return GET_RETURN_STATUS(env);
return napi_clear_last_error(env);
}

napi_status napi_get_array_length(napi_env env,
Expand Down Expand Up @@ -1772,7 +1772,7 @@ napi_status napi_get_value_string_latin1(napi_env env,
char* buf,
size_t bufsize,
size_t* result) {
NAPI_PREAMBLE(env);
CHECK_ENV(env);
CHECK_ARG(env, value);

v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value);
Expand All @@ -1792,7 +1792,7 @@ napi_status napi_get_value_string_latin1(napi_env env,
}
}

return GET_RETURN_STATUS(env);
return napi_clear_last_error(env);
}

// Copies a JavaScript string into a UTF-8 string buffer. The result is the
Expand All @@ -1808,7 +1808,7 @@ napi_status napi_get_value_string_utf8(napi_env env,
char* buf,
size_t bufsize,
size_t* result) {
NAPI_PREAMBLE(env);
CHECK_ENV(env);
CHECK_ARG(env, value);

v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value);
Expand All @@ -1828,7 +1828,7 @@ napi_status napi_get_value_string_utf8(napi_env env,
}
}

return GET_RETURN_STATUS(env);
return napi_clear_last_error(env);
}

// Copies a JavaScript string into a UTF-16 string buffer. The result is the
Expand All @@ -1844,7 +1844,7 @@ napi_status napi_get_value_string_utf16(napi_env env,
char16_t* buf,
size_t bufsize,
size_t* result) {
NAPI_PREAMBLE(env);
CHECK_ENV(env);
CHECK_ARG(env, value);

v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value);
Expand All @@ -1865,7 +1865,7 @@ napi_status napi_get_value_string_utf16(napi_env env,
}
}

return GET_RETURN_STATUS(env);
return napi_clear_last_error(env);
}

napi_status napi_coerce_to_object(napi_env env,
Expand Down Expand Up @@ -2019,13 +2019,13 @@ napi_status napi_create_external(napi_env env,

*result = v8impl::JsValueFromV8LocalValue(external_value);

return GET_RETURN_STATUS(env);
return napi_clear_last_error(env);
}

napi_status napi_get_value_external(napi_env env,
napi_value value,
void** result) {
NAPI_PREAMBLE(env);
CHECK_ENV(env);
CHECK_ARG(env, value);
CHECK_ARG(env, result);

Expand All @@ -2035,7 +2035,7 @@ napi_status napi_get_value_external(napi_env env,
v8::Local<v8::External> external_value = val.As<v8::External>();
*result = external_value->Value();

return GET_RETURN_STATUS(env);
return napi_clear_last_error(env);
}

// Set initial_refcount to 0 for a weak reference, >0 for a strong reference.
Expand Down Expand Up @@ -2476,12 +2476,12 @@ napi_status napi_create_buffer_copy(napi_env env,
}

napi_status napi_is_buffer(napi_env env, napi_value value, bool* result) {
NAPI_PREAMBLE(env);
CHECK_ENV(env);
CHECK_ARG(env, value);
CHECK_ARG(env, result);

*result = node::Buffer::HasInstance(v8impl::V8LocalValueFromJsValue(value));
return GET_RETURN_STATUS(env);
return napi_clear_last_error(env);
}

napi_status napi_get_buffer_info(napi_env env,
Expand All @@ -2505,14 +2505,14 @@ napi_status napi_get_buffer_info(napi_env env,
}

napi_status napi_is_arraybuffer(napi_env env, napi_value value, bool* result) {
NAPI_PREAMBLE(env);
CHECK_ENV(env);
CHECK_ARG(env, value);
CHECK_ARG(env, result);

v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value);
*result = val->IsArrayBuffer();

return GET_RETURN_STATUS(env);
return napi_clear_last_error(env);
}

napi_status napi_create_arraybuffer(napi_env env,
Expand Down Expand Up @@ -2569,7 +2569,7 @@ napi_status napi_get_arraybuffer_info(napi_env env,
napi_value arraybuffer,
void** data,
size_t* byte_length) {
NAPI_PREAMBLE(env);
CHECK_ENV(env);
CHECK_ARG(env, arraybuffer);

v8::Local<v8::Value> value = v8impl::V8LocalValueFromJsValue(arraybuffer);
Expand All @@ -2586,18 +2586,18 @@ napi_status napi_get_arraybuffer_info(napi_env env,
*byte_length = contents.ByteLength();
}

return GET_RETURN_STATUS(env);
return napi_clear_last_error(env);
}

napi_status napi_is_typedarray(napi_env env, napi_value value, bool* result) {
NAPI_PREAMBLE(env);
CHECK_ENV(env);
CHECK_ARG(env, value);
CHECK_ARG(env, result);

v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value);
*result = val->IsTypedArray();

return GET_RETURN_STATUS(env);
return napi_clear_last_error(env);
}

napi_status napi_create_typedarray(napi_env env,
Expand Down Expand Up @@ -2659,7 +2659,7 @@ napi_status napi_get_typedarray_info(napi_env env,
void** data,
napi_value* arraybuffer,
size_t* byte_offset) {
NAPI_PREAMBLE(env);
CHECK_ENV(env);
CHECK_ARG(env, typedarray);

v8::Local<v8::Value> value = v8impl::V8LocalValueFromJsValue(typedarray);
Expand Down Expand Up @@ -2707,7 +2707,7 @@ napi_status napi_get_typedarray_info(napi_env env,
*byte_offset = array->ByteOffset();
}

return GET_RETURN_STATUS(env);
return napi_clear_last_error(env);
}

namespace uvimpl {
Expand Down