summaryrefslogtreecommitdiff
path: root/src/stream_base.cc
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2018-04-16 22:58:19 +0800
committerJoyee Cheung <joyeec9h3@gmail.com>2018-04-19 12:09:26 +0800
commit2c23e31c317025f6064c194f8850a474f4b6bf53 (patch)
tree8f25f315719122321a912cf1bae35a6f76a51edf /src/stream_base.cc
parent7e269f52667104c94dcf65e527b04c2632d701bb (diff)
downloadandroid-node-v8-2c23e31c317025f6064c194f8850a474f4b6bf53.tar.gz
android-node-v8-2c23e31c317025f6064c194f8850a474f4b6bf53.tar.bz2
android-node-v8-2c23e31c317025f6064c194f8850a474f4b6bf53.zip
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/stream_base.cc')
-rw-r--r--src/stream_base.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/stream_base.cc b/src/stream_base.cc
index 880e1a968d..801b7f4b2f 100644
--- a/src/stream_base.cc
+++ b/src/stream_base.cc
@@ -3,6 +3,7 @@
#include "node.h"
#include "node_buffer.h"
+#include "node_errors.h"
#include "node_internals.h"
#include "env-inl.h"
#include "js_stream.h"
@@ -175,7 +176,7 @@ int StreamBase::WriteBuffer(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
if (!args[1]->IsUint8Array()) {
- env->ThrowTypeError("Second argument must be a buffer");
+ node::THROW_ERR_INVALID_ARG_TYPE(env, "Second argument must be a buffer");
return 0;
}