diff --git a/doc/api/errors.md b/doc/api/errors.md
index 784c9ac5a226d0..abcfa7b96f3d34 100644
--- a/doc/api/errors.md
+++ b/doc/api/errors.md
@@ -876,6 +876,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_DEBUGGER_ERROR`
+
+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 d852a8f67eb1fe..8b34d601146579 100644
--- a/src/node_binding.cc
+++ b/src/node_binding.cc
@@ -5,6 +5,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
@@ -416,13 +418,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