MCPcopy Create free account
hub / github.com/BabylonJS/BabylonNative / set_error_code

Function set_error_code

Dependencies/napi/source/js_native_api_v8.cc:1549–1574  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1547}
1548
1549static inline napi_status set_error_code(napi_env env,
1550 v8::Local<v8::Value> error,
1551 napi_value code,
1552 const char* code_cstring) {
1553 if ((code != nullptr) || (code_cstring != nullptr)) {
1554 v8::Local<v8::Context> context = env->context();
1555 v8::Local<v8::Object> err_object = error.As<v8::Object>();
1556
1557 v8::Local<v8::Value> code_value = v8impl::V8LocalValueFromJsValue(code);
1558 if (code != nullptr) {
1559 code_value = v8impl::V8LocalValueFromJsValue(code);
1560 RETURN_STATUS_IF_FALSE(env, code_value->IsString(), napi_string_expected);
1561 } else {
1562 CHECK_NEW_FROM_UTF8(env, code_value, code_cstring);
1563 }
1564
1565 v8::Local<v8::Name> code_key;
1566 CHECK_NEW_FROM_UTF8(env, code_key, "code");
1567
1568 v8::Maybe<bool> set_maybe = err_object->Set(context, code_key, code_value);
1569 RETURN_STATUS_IF_FALSE(env,
1570 set_maybe.FromMaybe(false),
1571 napi_generic_failure);
1572 }
1573 return napi_ok;
1574}
1575
1576napi_status napi_create_error(napi_env env,
1577 napi_value code,

Callers 6

napi_create_errorFunction · 0.85
napi_create_type_errorFunction · 0.85
napi_create_range_errorFunction · 0.85
napi_throw_errorFunction · 0.85
napi_throw_type_errorFunction · 0.85
napi_throw_range_errorFunction · 0.85

Calls 4

V8LocalValueFromJsValueFunction · 0.85
contextMethod · 0.80
IsStringMethod · 0.80
SetMethod · 0.80

Tested by

no test coverage detected