diff --git a/src/module_wrap.cc b/src/module_wrap.cc index b735fd8e3b3719..48af2daa1391c8 100644 --- a/src/module_wrap.cc +++ b/src/module_wrap.cc @@ -685,8 +685,7 @@ void ModuleWrap::Resolve(const FunctionCallbackInfo& args) { Maybe result = node::loader::Resolve(env, specifier_std, url); if (result.IsNothing() || (result.FromJust().flags() & URL_FLAGS_FAILED)) { std::string msg = "Cannot find module " + specifier_std; - env->ThrowError(msg.c_str()); - return; + return node::THROW_ERR_MISSING_MODULE(env, msg.c_str()); } args.GetReturnValue().Set(result.FromJust().ToObject(env)); diff --git a/src/node_errors.h b/src/node_errors.h index fadbdbe37408b1..133fb3ab96dc8c 100644 --- a/src/node_errors.h +++ b/src/node_errors.h @@ -21,6 +21,7 @@ namespace node { V(ERR_INDEX_OUT_OF_RANGE, RangeError) \ V(ERR_INVALID_ARG_TYPE, TypeError) \ V(ERR_MEMORY_ALLOCATION_FAILED, Error) \ + V(ERR_MISSING_MODULE, Error) \ V(ERR_STRING_TOO_LONG, Error) \ V(ERR_BUFFER_TOO_LARGE, Error)