diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-04-16 22:58:19 +0800 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2018-04-19 12:09:26 +0800 |
commit | 2c23e31c317025f6064c194f8850a474f4b6bf53 (patch) | |
tree | 8f25f315719122321a912cf1bae35a6f76a51edf /src/node_i18n.cc | |
parent | 7e269f52667104c94dcf65e527b04c2632d701bb (diff) | |
download | node-new-2c23e31c317025f6064c194f8850a474f4b6bf53.tar.gz |
src: throw ERR_INVALID_ARG_TYPE in C++ argument checks
- Moves THROW_AND_RETURN_IF_NOT_BUFFER and
THROW_AND_RETURN_IF_NOT_STRING from node_crypto.cc to
node_errors.h so it can be reused.
- Move THROW_AND_RETURN_UNLESS_BUFFER in util.h to
node_buffer.cc and call THROW_AND_RETURN_IF_NOT_BUFFER
there. The only other reference to THROW_AND_RETURN_UNLESS_BUFFER in
node_i18n.cc can be safely replaced by an assertion since
the argument will be checked in JS land.
- Migrate ERR_INVALID_ARG_TYPE errors in C++. We can move the
checks to JS land if possible later without having to
go semver-major.
PR-URL: https://github.com/nodejs/node/pull/20121
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'src/node_i18n.cc')
-rw-r--r-- | src/node_i18n.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/node_i18n.cc b/src/node_i18n.cc index 7f462d5aea..f491d2191d 100644 --- a/src/node_i18n.cc +++ b/src/node_i18n.cc @@ -46,6 +46,7 @@ #include "node.h" #include "node_buffer.h" +#include "node_errors.h" #include "env-inl.h" #include "util-inl.h" #include "base_object-inl.h" @@ -447,7 +448,7 @@ void Transcode(const FunctionCallbackInfo<Value>&args) { UErrorCode status = U_ZERO_ERROR; MaybeLocal<Object> result; - THROW_AND_RETURN_UNLESS_BUFFER(env, args[0]); + CHECK(Buffer::HasInstance(args[0])); SPREAD_BUFFER_ARG(args[0], ts_obj); const enum encoding fromEncoding = ParseEncoding(isolate, args[1], BUFFER); const enum encoding toEncoding = ParseEncoding(isolate, args[2], BUFFER); |