11cb0ef41Sopenharmony_ci#ifndef SRC_NODE_ERRORS_H_ 21cb0ef41Sopenharmony_ci#define SRC_NODE_ERRORS_H_ 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ci#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ci#include "debug_utils-inl.h" 71cb0ef41Sopenharmony_ci#include "env.h" 81cb0ef41Sopenharmony_ci#include "v8.h" 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ci// Use ostringstream to print exact-width integer types 111cb0ef41Sopenharmony_ci// because the format specifiers are not available on AIX. 121cb0ef41Sopenharmony_ci#include <sstream> 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_cinamespace node { 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_cienum ErrorHandlingMode { CONTEXTIFY_ERROR, FATAL_ERROR, MODULE_ERROR }; 171cb0ef41Sopenharmony_civoid AppendExceptionLine(Environment* env, 181cb0ef41Sopenharmony_ci v8::Local<v8::Value> er, 191cb0ef41Sopenharmony_ci v8::Local<v8::Message> message, 201cb0ef41Sopenharmony_ci enum ErrorHandlingMode mode); 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ci[[noreturn]] void FatalError(const char* location, const char* message); 231cb0ef41Sopenharmony_ci[[noreturn]] void OnFatalError(const char* location, const char* message); 241cb0ef41Sopenharmony_ci[[noreturn]] void OOMErrorHandler(const char* location, const v8::OOMDetails& details); 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ci// Helpers to construct errors similar to the ones provided by 271cb0ef41Sopenharmony_ci// lib/internal/errors.js. 281cb0ef41Sopenharmony_ci// Example: with `V(ERR_INVALID_ARG_TYPE, TypeError)`, there will be 291cb0ef41Sopenharmony_ci// `node::ERR_INVALID_ARG_TYPE(isolate, "message")` returning 301cb0ef41Sopenharmony_ci// a `Local<Value>` containing the TypeError with proper code and message 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ci#define ERRORS_WITH_CODE(V) \ 331cb0ef41Sopenharmony_ci V(ERR_BUFFER_CONTEXT_NOT_AVAILABLE, Error) \ 341cb0ef41Sopenharmony_ci V(ERR_BUFFER_OUT_OF_BOUNDS, RangeError) \ 351cb0ef41Sopenharmony_ci V(ERR_BUFFER_TOO_LARGE, Error) \ 361cb0ef41Sopenharmony_ci V(ERR_CLOSED_MESSAGE_PORT, Error) \ 371cb0ef41Sopenharmony_ci V(ERR_CONSTRUCT_CALL_REQUIRED, TypeError) \ 381cb0ef41Sopenharmony_ci V(ERR_CONSTRUCT_CALL_INVALID, TypeError) \ 391cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INITIALIZATION_FAILED, Error) \ 401cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INVALID_AUTH_TAG, TypeError) \ 411cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INVALID_COUNTER, TypeError) \ 421cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INVALID_CURVE, TypeError) \ 431cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INVALID_DIGEST, TypeError) \ 441cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INVALID_IV, TypeError) \ 451cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INVALID_JWK, TypeError) \ 461cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INVALID_KEYLEN, RangeError) \ 471cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INVALID_KEYPAIR, RangeError) \ 481cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INVALID_KEYTYPE, RangeError) \ 491cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INVALID_MESSAGELEN, RangeError) \ 501cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INVALID_SCRYPT_PARAMS, RangeError) \ 511cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INVALID_STATE, Error) \ 521cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INVALID_TAG_LENGTH, RangeError) \ 531cb0ef41Sopenharmony_ci V(ERR_CRYPTO_JWK_UNSUPPORTED_CURVE, Error) \ 541cb0ef41Sopenharmony_ci V(ERR_CRYPTO_JWK_UNSUPPORTED_KEY_TYPE, Error) \ 551cb0ef41Sopenharmony_ci V(ERR_CRYPTO_OPERATION_FAILED, Error) \ 561cb0ef41Sopenharmony_ci V(ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH, RangeError) \ 571cb0ef41Sopenharmony_ci V(ERR_CRYPTO_UNKNOWN_CIPHER, Error) \ 581cb0ef41Sopenharmony_ci V(ERR_CRYPTO_UNKNOWN_DH_GROUP, Error) \ 591cb0ef41Sopenharmony_ci V(ERR_CRYPTO_UNSUPPORTED_OPERATION, Error) \ 601cb0ef41Sopenharmony_ci V(ERR_CRYPTO_JOB_INIT_FAILED, Error) \ 611cb0ef41Sopenharmony_ci V(ERR_DLOPEN_DISABLED, Error) \ 621cb0ef41Sopenharmony_ci V(ERR_DLOPEN_FAILED, Error) \ 631cb0ef41Sopenharmony_ci V(ERR_ENCODING_INVALID_ENCODED_DATA, TypeError) \ 641cb0ef41Sopenharmony_ci V(ERR_EXECUTION_ENVIRONMENT_NOT_AVAILABLE, Error) \ 651cb0ef41Sopenharmony_ci V(ERR_ILLEGAL_CONSTRUCTOR, Error) \ 661cb0ef41Sopenharmony_ci V(ERR_INVALID_ADDRESS, Error) \ 671cb0ef41Sopenharmony_ci V(ERR_INVALID_ARG_VALUE, TypeError) \ 681cb0ef41Sopenharmony_ci V(ERR_OSSL_EVP_INVALID_DIGEST, Error) \ 691cb0ef41Sopenharmony_ci V(ERR_INVALID_ARG_TYPE, TypeError) \ 701cb0ef41Sopenharmony_ci V(ERR_INVALID_OBJECT_DEFINE_PROPERTY, TypeError) \ 711cb0ef41Sopenharmony_ci V(ERR_INVALID_MODULE, Error) \ 721cb0ef41Sopenharmony_ci V(ERR_INVALID_STATE, Error) \ 731cb0ef41Sopenharmony_ci V(ERR_INVALID_THIS, TypeError) \ 741cb0ef41Sopenharmony_ci V(ERR_INVALID_TRANSFER_OBJECT, TypeError) \ 751cb0ef41Sopenharmony_ci V(ERR_MEMORY_ALLOCATION_FAILED, Error) \ 761cb0ef41Sopenharmony_ci V(ERR_MESSAGE_TARGET_CONTEXT_UNAVAILABLE, Error) \ 771cb0ef41Sopenharmony_ci V(ERR_MISSING_ARGS, TypeError) \ 781cb0ef41Sopenharmony_ci V(ERR_MISSING_TRANSFERABLE_IN_TRANSFER_LIST, TypeError) \ 791cb0ef41Sopenharmony_ci V(ERR_MISSING_PASSPHRASE, TypeError) \ 801cb0ef41Sopenharmony_ci V(ERR_MISSING_PLATFORM_FOR_WORKER, Error) \ 811cb0ef41Sopenharmony_ci V(ERR_NON_CONTEXT_AWARE_DISABLED, Error) \ 821cb0ef41Sopenharmony_ci V(ERR_OUT_OF_RANGE, RangeError) \ 831cb0ef41Sopenharmony_ci V(ERR_SCRIPT_EXECUTION_INTERRUPTED, Error) \ 841cb0ef41Sopenharmony_ci V(ERR_SCRIPT_EXECUTION_TIMEOUT, Error) \ 851cb0ef41Sopenharmony_ci V(ERR_STRING_TOO_LONG, Error) \ 861cb0ef41Sopenharmony_ci V(ERR_TLS_INVALID_PROTOCOL_METHOD, TypeError) \ 871cb0ef41Sopenharmony_ci V(ERR_TLS_PSK_SET_IDENTIY_HINT_FAILED, Error) \ 881cb0ef41Sopenharmony_ci V(ERR_VM_MODULE_CACHED_DATA_REJECTED, Error) \ 891cb0ef41Sopenharmony_ci V(ERR_VM_MODULE_LINK_FAILURE, Error) \ 901cb0ef41Sopenharmony_ci V(ERR_WASI_NOT_STARTED, Error) \ 911cb0ef41Sopenharmony_ci V(ERR_WORKER_INIT_FAILED, Error) \ 921cb0ef41Sopenharmony_ci V(ERR_PROTO_ACCESS, Error) 931cb0ef41Sopenharmony_ci 941cb0ef41Sopenharmony_ci#define V(code, type) \ 951cb0ef41Sopenharmony_ci template <typename... Args> \ 961cb0ef41Sopenharmony_ci inline v8::Local<v8::Value> code( \ 971cb0ef41Sopenharmony_ci v8::Isolate* isolate, const char* format, Args&&... args) { \ 981cb0ef41Sopenharmony_ci std::string message = SPrintF(format, std::forward<Args>(args)...); \ 991cb0ef41Sopenharmony_ci v8::Local<v8::String> js_code = OneByteString(isolate, #code); \ 1001cb0ef41Sopenharmony_ci v8::Local<v8::String> js_msg = \ 1011cb0ef41Sopenharmony_ci OneByteString(isolate, message.c_str(), message.length()); \ 1021cb0ef41Sopenharmony_ci v8::Local<v8::Object> e = v8::Exception::type(js_msg) \ 1031cb0ef41Sopenharmony_ci ->ToObject(isolate->GetCurrentContext()) \ 1041cb0ef41Sopenharmony_ci .ToLocalChecked(); \ 1051cb0ef41Sopenharmony_ci e->Set(isolate->GetCurrentContext(), \ 1061cb0ef41Sopenharmony_ci OneByteString(isolate, "code"), \ 1071cb0ef41Sopenharmony_ci js_code) \ 1081cb0ef41Sopenharmony_ci .Check(); \ 1091cb0ef41Sopenharmony_ci return e; \ 1101cb0ef41Sopenharmony_ci } \ 1111cb0ef41Sopenharmony_ci template <typename... Args> \ 1121cb0ef41Sopenharmony_ci inline void THROW_##code( \ 1131cb0ef41Sopenharmony_ci v8::Isolate* isolate, const char* format, Args&&... args) { \ 1141cb0ef41Sopenharmony_ci isolate->ThrowException( \ 1151cb0ef41Sopenharmony_ci code(isolate, format, std::forward<Args>(args)...)); \ 1161cb0ef41Sopenharmony_ci } \ 1171cb0ef41Sopenharmony_ci template <typename... Args> \ 1181cb0ef41Sopenharmony_ci inline void THROW_##code( \ 1191cb0ef41Sopenharmony_ci Environment* env, const char* format, Args&&... args) { \ 1201cb0ef41Sopenharmony_ci THROW_##code(env->isolate(), format, std::forward<Args>(args)...); \ 1211cb0ef41Sopenharmony_ci } 1221cb0ef41Sopenharmony_ciERRORS_WITH_CODE(V) 1231cb0ef41Sopenharmony_ci#undef V 1241cb0ef41Sopenharmony_ci 1251cb0ef41Sopenharmony_ci// Errors with predefined static messages 1261cb0ef41Sopenharmony_ci 1271cb0ef41Sopenharmony_ci#define PREDEFINED_ERROR_MESSAGES(V) \ 1281cb0ef41Sopenharmony_ci V(ERR_BUFFER_CONTEXT_NOT_AVAILABLE, \ 1291cb0ef41Sopenharmony_ci "Buffer is not available for the current Context") \ 1301cb0ef41Sopenharmony_ci V(ERR_CLOSED_MESSAGE_PORT, "Cannot send data on closed MessagePort") \ 1311cb0ef41Sopenharmony_ci V(ERR_CONSTRUCT_CALL_INVALID, "Constructor cannot be called") \ 1321cb0ef41Sopenharmony_ci V(ERR_CONSTRUCT_CALL_REQUIRED, "Cannot call constructor without `new`") \ 1331cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INITIALIZATION_FAILED, "Initialization failed") \ 1341cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INVALID_AUTH_TAG, "Invalid authentication tag") \ 1351cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INVALID_COUNTER, "Invalid counter") \ 1361cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INVALID_CURVE, "Invalid EC curve name") \ 1371cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INVALID_DIGEST, "Invalid digest") \ 1381cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INVALID_IV, "Invalid initialization vector") \ 1391cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INVALID_JWK, "Invalid JWK format") \ 1401cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INVALID_KEYLEN, "Invalid key length") \ 1411cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INVALID_KEYPAIR, "Invalid key pair") \ 1421cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INVALID_KEYTYPE, "Invalid key type") \ 1431cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INVALID_MESSAGELEN, "Invalid message length") \ 1441cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INVALID_SCRYPT_PARAMS, "Invalid scrypt params") \ 1451cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INVALID_STATE, "Invalid state") \ 1461cb0ef41Sopenharmony_ci V(ERR_CRYPTO_INVALID_TAG_LENGTH, "Invalid taglength") \ 1471cb0ef41Sopenharmony_ci V(ERR_CRYPTO_JWK_UNSUPPORTED_KEY_TYPE, "Unsupported JWK Key Type.") \ 1481cb0ef41Sopenharmony_ci V(ERR_CRYPTO_OPERATION_FAILED, "Operation failed") \ 1491cb0ef41Sopenharmony_ci V(ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH, \ 1501cb0ef41Sopenharmony_ci "Input buffers must have the same byte length") \ 1511cb0ef41Sopenharmony_ci V(ERR_CRYPTO_UNKNOWN_CIPHER, "Unknown cipher") \ 1521cb0ef41Sopenharmony_ci V(ERR_CRYPTO_UNKNOWN_DH_GROUP, "Unknown DH group") \ 1531cb0ef41Sopenharmony_ci V(ERR_CRYPTO_UNSUPPORTED_OPERATION, "Unsupported crypto operation") \ 1541cb0ef41Sopenharmony_ci V(ERR_CRYPTO_JOB_INIT_FAILED, "Failed to initialize crypto job config") \ 1551cb0ef41Sopenharmony_ci V(ERR_DLOPEN_FAILED, "DLOpen failed") \ 1561cb0ef41Sopenharmony_ci V(ERR_EXECUTION_ENVIRONMENT_NOT_AVAILABLE, \ 1571cb0ef41Sopenharmony_ci "Context not associated with Node.js environment") \ 1581cb0ef41Sopenharmony_ci V(ERR_ILLEGAL_CONSTRUCTOR, "Illegal constructor") \ 1591cb0ef41Sopenharmony_ci V(ERR_INVALID_ADDRESS, "Invalid socket address") \ 1601cb0ef41Sopenharmony_ci V(ERR_INVALID_MODULE, "No such module") \ 1611cb0ef41Sopenharmony_ci V(ERR_INVALID_THIS, "Value of \"this\" is the wrong type") \ 1621cb0ef41Sopenharmony_ci V(ERR_INVALID_TRANSFER_OBJECT, "Found invalid object in transferList") \ 1631cb0ef41Sopenharmony_ci V(ERR_MEMORY_ALLOCATION_FAILED, "Failed to allocate memory") \ 1641cb0ef41Sopenharmony_ci V(ERR_OSSL_EVP_INVALID_DIGEST, "Invalid digest used") \ 1651cb0ef41Sopenharmony_ci V(ERR_MESSAGE_TARGET_CONTEXT_UNAVAILABLE, \ 1661cb0ef41Sopenharmony_ci "A message object could not be deserialized successfully in the target " \ 1671cb0ef41Sopenharmony_ci "vm.Context") \ 1681cb0ef41Sopenharmony_ci V(ERR_MISSING_TRANSFERABLE_IN_TRANSFER_LIST, \ 1691cb0ef41Sopenharmony_ci "Object that needs transfer was found in message but not listed " \ 1701cb0ef41Sopenharmony_ci "in transferList") \ 1711cb0ef41Sopenharmony_ci V(ERR_MISSING_PLATFORM_FOR_WORKER, \ 1721cb0ef41Sopenharmony_ci "The V8 platform used by this instance of Node does not support " \ 1731cb0ef41Sopenharmony_ci "creating Workers") \ 1741cb0ef41Sopenharmony_ci V(ERR_NON_CONTEXT_AWARE_DISABLED, \ 1751cb0ef41Sopenharmony_ci "Loading non context-aware native addons has been disabled") \ 1761cb0ef41Sopenharmony_ci V(ERR_SCRIPT_EXECUTION_INTERRUPTED, \ 1771cb0ef41Sopenharmony_ci "Script execution was interrupted by `SIGINT`") \ 1781cb0ef41Sopenharmony_ci V(ERR_TLS_PSK_SET_IDENTIY_HINT_FAILED, "Failed to set PSK identity hint") \ 1791cb0ef41Sopenharmony_ci V(ERR_WASI_NOT_STARTED, "wasi.start() has not been called") \ 1801cb0ef41Sopenharmony_ci V(ERR_WORKER_INIT_FAILED, "Worker initialization failure") \ 1811cb0ef41Sopenharmony_ci V(ERR_PROTO_ACCESS, \ 1821cb0ef41Sopenharmony_ci "Accessing Object.prototype.__proto__ has been " \ 1831cb0ef41Sopenharmony_ci "disallowed with --disable-proto=throw") 1841cb0ef41Sopenharmony_ci 1851cb0ef41Sopenharmony_ci#define V(code, message) \ 1861cb0ef41Sopenharmony_ci inline v8::Local<v8::Value> code(v8::Isolate* isolate) { \ 1871cb0ef41Sopenharmony_ci return code(isolate, message); \ 1881cb0ef41Sopenharmony_ci } \ 1891cb0ef41Sopenharmony_ci inline void THROW_ ## code(v8::Isolate* isolate) { \ 1901cb0ef41Sopenharmony_ci isolate->ThrowException(code(isolate, message)); \ 1911cb0ef41Sopenharmony_ci } \ 1921cb0ef41Sopenharmony_ci inline void THROW_ ## code(Environment* env) { \ 1931cb0ef41Sopenharmony_ci THROW_ ## code(env->isolate()); \ 1941cb0ef41Sopenharmony_ci } 1951cb0ef41Sopenharmony_ci PREDEFINED_ERROR_MESSAGES(V) 1961cb0ef41Sopenharmony_ci#undef V 1971cb0ef41Sopenharmony_ci 1981cb0ef41Sopenharmony_ci// Errors with predefined non-static messages 1991cb0ef41Sopenharmony_ciinline void THROW_ERR_SCRIPT_EXECUTION_TIMEOUT(Environment* env, 2001cb0ef41Sopenharmony_ci int64_t timeout) { 2011cb0ef41Sopenharmony_ci std::ostringstream message; 2021cb0ef41Sopenharmony_ci message << "Script execution timed out after "; 2031cb0ef41Sopenharmony_ci message << timeout << "ms"; 2041cb0ef41Sopenharmony_ci THROW_ERR_SCRIPT_EXECUTION_TIMEOUT(env, message.str().c_str()); 2051cb0ef41Sopenharmony_ci} 2061cb0ef41Sopenharmony_ci 2071cb0ef41Sopenharmony_ciinline v8::Local<v8::Value> ERR_BUFFER_TOO_LARGE(v8::Isolate* isolate) { 2081cb0ef41Sopenharmony_ci char message[128]; 2091cb0ef41Sopenharmony_ci snprintf(message, sizeof(message), 2101cb0ef41Sopenharmony_ci "Cannot create a Buffer larger than 0x%zx bytes", 2111cb0ef41Sopenharmony_ci v8::TypedArray::kMaxLength); 2121cb0ef41Sopenharmony_ci return ERR_BUFFER_TOO_LARGE(isolate, message); 2131cb0ef41Sopenharmony_ci} 2141cb0ef41Sopenharmony_ci 2151cb0ef41Sopenharmony_ciinline v8::Local<v8::Value> ERR_STRING_TOO_LONG(v8::Isolate* isolate) { 2161cb0ef41Sopenharmony_ci char message[128]; 2171cb0ef41Sopenharmony_ci snprintf(message, sizeof(message), 2181cb0ef41Sopenharmony_ci "Cannot create a string longer than 0x%x characters", 2191cb0ef41Sopenharmony_ci v8::String::kMaxLength); 2201cb0ef41Sopenharmony_ci return ERR_STRING_TOO_LONG(isolate, message); 2211cb0ef41Sopenharmony_ci} 2221cb0ef41Sopenharmony_ci 2231cb0ef41Sopenharmony_ci#define THROW_AND_RETURN_IF_NOT_BUFFER(env, val, prefix) \ 2241cb0ef41Sopenharmony_ci do { \ 2251cb0ef41Sopenharmony_ci if (!Buffer::HasInstance(val)) \ 2261cb0ef41Sopenharmony_ci return node::THROW_ERR_INVALID_ARG_TYPE(env, \ 2271cb0ef41Sopenharmony_ci prefix " must be a buffer"); \ 2281cb0ef41Sopenharmony_ci } while (0) 2291cb0ef41Sopenharmony_ci 2301cb0ef41Sopenharmony_ci#define THROW_AND_RETURN_IF_NOT_STRING(env, val, prefix) \ 2311cb0ef41Sopenharmony_ci do { \ 2321cb0ef41Sopenharmony_ci if (!val->IsString()) \ 2331cb0ef41Sopenharmony_ci return node::THROW_ERR_INVALID_ARG_TYPE(env, \ 2341cb0ef41Sopenharmony_ci prefix " must be a string"); \ 2351cb0ef41Sopenharmony_ci } while (0) 2361cb0ef41Sopenharmony_ci 2371cb0ef41Sopenharmony_cinamespace errors { 2381cb0ef41Sopenharmony_ci 2391cb0ef41Sopenharmony_ciclass TryCatchScope : public v8::TryCatch { 2401cb0ef41Sopenharmony_ci public: 2411cb0ef41Sopenharmony_ci enum class CatchMode { kNormal, kFatal }; 2421cb0ef41Sopenharmony_ci 2431cb0ef41Sopenharmony_ci explicit TryCatchScope(Environment* env, CatchMode mode = CatchMode::kNormal) 2441cb0ef41Sopenharmony_ci : v8::TryCatch(env->isolate()), env_(env), mode_(mode) {} 2451cb0ef41Sopenharmony_ci ~TryCatchScope(); 2461cb0ef41Sopenharmony_ci 2471cb0ef41Sopenharmony_ci // Since the dtor is not virtual we need to make sure no one creates 2481cb0ef41Sopenharmony_ci // object of it in the free store that might be held by polymorphic pointers. 2491cb0ef41Sopenharmony_ci void* operator new(std::size_t count) = delete; 2501cb0ef41Sopenharmony_ci void* operator new[](std::size_t count) = delete; 2511cb0ef41Sopenharmony_ci TryCatchScope(TryCatchScope&) = delete; 2521cb0ef41Sopenharmony_ci TryCatchScope(TryCatchScope&&) = delete; 2531cb0ef41Sopenharmony_ci TryCatchScope operator=(TryCatchScope&) = delete; 2541cb0ef41Sopenharmony_ci TryCatchScope operator=(TryCatchScope&&) = delete; 2551cb0ef41Sopenharmony_ci 2561cb0ef41Sopenharmony_ci private: 2571cb0ef41Sopenharmony_ci Environment* env_; 2581cb0ef41Sopenharmony_ci CatchMode mode_; 2591cb0ef41Sopenharmony_ci}; 2601cb0ef41Sopenharmony_ci 2611cb0ef41Sopenharmony_ci// Trigger the global uncaught exception handler `process._fatalException` 2621cb0ef41Sopenharmony_ci// in JS land (which emits the 'uncaughtException' event). If that returns 2631cb0ef41Sopenharmony_ci// true, continue program execution, otherwise exit the process. 2641cb0ef41Sopenharmony_civoid TriggerUncaughtException(v8::Isolate* isolate, 2651cb0ef41Sopenharmony_ci const v8::TryCatch& try_catch); 2661cb0ef41Sopenharmony_civoid TriggerUncaughtException(v8::Isolate* isolate, 2671cb0ef41Sopenharmony_ci v8::Local<v8::Value> error, 2681cb0ef41Sopenharmony_ci v8::Local<v8::Message> message, 2691cb0ef41Sopenharmony_ci bool from_promise = false); 2701cb0ef41Sopenharmony_ci 2711cb0ef41Sopenharmony_ciconst char* errno_string(int errorno); 2721cb0ef41Sopenharmony_civoid PerIsolateMessageListener(v8::Local<v8::Message> message, 2731cb0ef41Sopenharmony_ci v8::Local<v8::Value> error); 2741cb0ef41Sopenharmony_ci 2751cb0ef41Sopenharmony_civoid DecorateErrorStack(Environment* env, 2761cb0ef41Sopenharmony_ci const errors::TryCatchScope& try_catch); 2771cb0ef41Sopenharmony_ci} // namespace errors 2781cb0ef41Sopenharmony_ci 2791cb0ef41Sopenharmony_civ8::ModifyCodeGenerationFromStringsResult ModifyCodeGenerationFromStrings( 2801cb0ef41Sopenharmony_ci v8::Local<v8::Context> context, 2811cb0ef41Sopenharmony_ci v8::Local<v8::Value> source, 2821cb0ef41Sopenharmony_ci bool is_code_like); 2831cb0ef41Sopenharmony_ci 2841cb0ef41Sopenharmony_ci} // namespace node 2851cb0ef41Sopenharmony_ci 2861cb0ef41Sopenharmony_ci#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 2871cb0ef41Sopenharmony_ci 2881cb0ef41Sopenharmony_ci#endif // SRC_NODE_ERRORS_H_ 289