diff --git a/doc/api/errors.md b/doc/api/errors.md
index 1c98ce88fb464b..9f12a9cba1a923 100644
--- a/doc/api/errors.md
+++ b/doc/api/errors.md
@@ -960,6 +960,14 @@ An unknown cipher was specified.
An unknown Diffie-Hellman group name was given. See
[`crypto.getDiffieHellman()`][] for a list of valid group names.
+
+### `ERR_DLOPEN_FAILED`
+
+
+A call to `process.dlopen()` failed.
+
### `ERR_DIR_CLOSED`
@@ -1502,6 +1510,15 @@ An invalid HTTP token was supplied.
An IP address is not valid.
+
+### `ERR_INVALID_MODULE`
+
+
+An attempt was made to load a module that does not exist or was otherwise not
+valid.
+
### `ERR_INVALID_MODULE_SPECIFIER`
diff --git a/src/node_binding.cc b/src/node_binding.cc
index 0d577a8c8e82eb..0db930adff1a9f 100644
--- a/src/node_binding.cc
+++ b/src/node_binding.cc
@@ -6,6 +6,8 @@
#include "node_native_module_env.h"
#include "util.h"
+#include
+
#if HAVE_OPENSSL
#define NODE_BUILTIN_OPENSSL_MODULES(V) V(crypto) V(tls_wrap)
#else
@@ -424,13 +426,13 @@ void DLOpen(const FunctionCallbackInfo& args) {
CHECK_NULL(thread_local_modpending);
if (args.Length() < 2) {
- env->ThrowError("process.dlopen needs at least 2 arguments.");
- return;
+ return THROW_ERR_MISSING_ARGS(
+ env, "process.dlopen needs at least 2 arguments");
}
int32_t flags = DLib::kDefaultFlags;
if (args.Length() > 2 && !args[2]->Int32Value(context).To(&flags)) {
- return env->ThrowTypeError("flag argument must be an integer.");
+ return THROW_ERR_INVALID_ARG_TYPE(env, "flag argument must be an integer.");
}
Local