Skip to content

Commit eb322bb

Browse files
committed
src: move node_contextify to modern THROW_ERR_*
Signed-off-by: James M Snell <[email protected]> PR-URL: #35470 Reviewed-By: Joyee Cheung <[email protected]>
1 parent b28ba4b commit eb322bb

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/node_contextify.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,8 @@ bool ContextifyScript::EvalMachine(Environment* env,
927927
if (!env->can_call_into_js())
928928
return false;
929929
if (!ContextifyScript::InstanceOf(env, args.Holder())) {
930-
env->ThrowTypeError(
930+
THROW_ERR_INVALID_THIS(
931+
env,
931932
"Script methods can only be called on script instances.");
932933
return false;
933934
}

src/node_errors.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ void OnFatalError(const char* location, const char* message);
5757
V(ERR_INVALID_ARG_VALUE, TypeError) \
5858
V(ERR_OSSL_EVP_INVALID_DIGEST, Error) \
5959
V(ERR_INVALID_ARG_TYPE, TypeError) \
60+
V(ERR_INVALID_THIS, TypeError) \
6061
V(ERR_INVALID_TRANSFER_OBJECT, TypeError) \
6162
V(ERR_MEMORY_ALLOCATION_FAILED, Error) \
6263
V(ERR_MESSAGE_TARGET_CONTEXT_UNAVAILABLE, Error) \
@@ -129,6 +130,7 @@ void OnFatalError(const char* location, const char* message);
129130
V(ERR_CRYPTO_JOB_INIT_FAILED, "Failed to initialize crypto job config") \
130131
V(ERR_EXECUTION_ENVIRONMENT_NOT_AVAILABLE, \
131132
"Context not associated with Node.js environment") \
133+
V(ERR_INVALID_THIS, "Value of \"this\" is the wrong type") \
132134
V(ERR_INVALID_TRANSFER_OBJECT, "Found invalid object in transferList") \
133135
V(ERR_MEMORY_ALLOCATION_FAILED, "Failed to allocate memory") \
134136
V(ERR_OSSL_EVP_INVALID_DIGEST, "Invalid digest used") \

0 commit comments

Comments
 (0)