diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 06a8e4a4beab4f..848e883a829a97 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -927,7 +927,8 @@ bool ContextifyScript::EvalMachine(Environment* env, if (!env->can_call_into_js()) return false; if (!ContextifyScript::InstanceOf(env, args.Holder())) { - env->ThrowTypeError( + THROW_ERR_INVALID_THIS( + env, "Script methods can only be called on script instances."); return false; } diff --git a/src/node_errors.h b/src/node_errors.h index 921fb09887f9e7..bfe166c053e6b0 100644 --- a/src/node_errors.h +++ b/src/node_errors.h @@ -40,6 +40,7 @@ void OnFatalError(const char* location, const char* message); V(ERR_INVALID_ARG_VALUE, TypeError) \ V(ERR_OSSL_EVP_INVALID_DIGEST, Error) \ V(ERR_INVALID_ARG_TYPE, TypeError) \ + V(ERR_INVALID_THIS, TypeError) \ V(ERR_INVALID_TRANSFER_OBJECT, TypeError) \ V(ERR_MEMORY_ALLOCATION_FAILED, Error) \ V(ERR_MESSAGE_TARGET_CONTEXT_UNAVAILABLE, Error) \ @@ -95,6 +96,7 @@ void OnFatalError(const char* location, const char* message); V(ERR_CRYPTO_UNKNOWN_DH_GROUP, "Unknown DH group") \ V(ERR_EXECUTION_ENVIRONMENT_NOT_AVAILABLE, \ "Context not associated with Node.js environment") \ + V(ERR_INVALID_THIS, "Value of \"this\" is the wrong type") \ V(ERR_INVALID_TRANSFER_OBJECT, "Found invalid object in transferList") \ V(ERR_MEMORY_ALLOCATION_FAILED, "Failed to allocate memory") \ V(ERR_OSSL_EVP_INVALID_DIGEST, "Invalid digest used") \