Don't mask exceptions generated from loadModule

Reviewed By: davidaurelio

Differential Revision: D4112447

fbshipit-source-id: e9b3a5cefb166fe00c04b6126c9878e71f1413ec
This commit is contained in:
Pieter De Baets 2016-11-01 16:09:49 -07:00 committed by Facebook Github Bot
parent 8bb707b686
commit 4082a54649

View File

@ -698,15 +698,12 @@ JSValueRef JSCExecutor::nativeRequire(
}
double moduleId = Value(m_context, arguments[0]).asNumber();
if (moduleId <= (double) std::numeric_limits<uint32_t>::max() && moduleId >= 0.0) {
try {
loadModule(moduleId);
} catch (const std::exception&) {
throw std::invalid_argument(folly::to<std::string>("Received invalid module ID: ", moduleId));
}
} else {
throw std::invalid_argument(folly::to<std::string>("Received invalid module ID: ", moduleId));
if (moduleId <= 0) {
throw std::invalid_argument(folly::to<std::string>("Received invalid module ID: ",
Value(m_context, arguments[0]).toString().str()));
}
loadModule(moduleId);
return JSValueMakeUndefined(m_context);
}