Skip to content

Commit 5946b1e

Browse files
jasnellMylesBorins
authored andcommitted
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 541082c commit 5946b1e

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/node_contextify.cc

+2-1
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

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ void OnFatalError(const char* location, const char* message);
4040
V(ERR_INVALID_ARG_VALUE, TypeError) \
4141
V(ERR_OSSL_EVP_INVALID_DIGEST, Error) \
4242
V(ERR_INVALID_ARG_TYPE, TypeError) \
43+
V(ERR_INVALID_THIS, TypeError) \
4344
V(ERR_INVALID_TRANSFER_OBJECT, TypeError) \
4445
V(ERR_MEMORY_ALLOCATION_FAILED, Error) \
4546
V(ERR_MESSAGE_TARGET_CONTEXT_UNAVAILABLE, Error) \
@@ -93,6 +94,7 @@ void OnFatalError(const char* location, const char* message);
9394
V(ERR_CRYPTO_UNKNOWN_DH_GROUP, "Unknown DH group") \
9495
V(ERR_EXECUTION_ENVIRONMENT_NOT_AVAILABLE, \
9596
"Context not associated with Node.js environment") \
97+
V(ERR_INVALID_THIS, "Value of \"this\" is the wrong type") \
9698
V(ERR_INVALID_TRANSFER_OBJECT, "Found invalid object in transferList") \
9799
V(ERR_MEMORY_ALLOCATION_FAILED, "Failed to allocate memory") \
98100
V(ERR_OSSL_EVP_INVALID_DIGEST, "Invalid digest used") \

0 commit comments

Comments
 (0)