Remove some throw specifications

Reviewed By: mhorowitz

Differential Revision: D3588394

fbshipit-source-id: 56e24f28b1f4eba2564007b395afcac6fa5cb209
This commit is contained in:
Chris Hopman
2016-07-21 17:32:42 -07:00
committed by Facebook Github Bot 3
parent 20f48debb6
commit e7fba4c123
4 changed files with 56 additions and 34 deletions

View File

@@ -340,42 +340,64 @@ void JSCExecutor::bindBridge() throw(JSException) {
m_flushedQueueJS = batchedBridge.getProperty("flushedQueue").asObject();
}
void JSCExecutor::flush() throw(JSException) {
void JSCExecutor::flush() {
auto result = m_flushedQueueJS->callAsFunction({});
auto calls = Value(m_context, result).toJSONString();
m_delegate->callNativeModules(*this, std::move(calls), true);
try {
auto calls = Value(m_context, result).toJSONString();
m_delegate->callNativeModules(*this, std::move(calls), true);
} catch (...) {
std::string message = "Error in flush()";
try {
message += ":" + Value(m_context, result).toString().str();
} catch (...) {
// ignored
}
std::throw_with_nested(std::runtime_error(message));
}
}
void JSCExecutor::callFunction(const std::string& moduleId, const std::string& methodId, const folly::dynamic& arguments) throw(JSException) {
auto result = m_callFunctionReturnFlushedQueueJS->callAsFunction({
Value(m_context, String::createExpectingAscii(moduleId)),
Value(m_context, String::createExpectingAscii(methodId)),
Value::fromDynamic(m_context, std::move(arguments))
});
auto calls = Value(m_context, result).toJSONString();
m_delegate->callNativeModules(*this, std::move(calls), true);
void JSCExecutor::callFunction(const std::string& moduleId, const std::string& methodId, const folly::dynamic& arguments) {
try {
auto result = m_callFunctionReturnFlushedQueueJS->callAsFunction({
Value(m_context, String::createExpectingAscii(moduleId)),
Value(m_context, String::createExpectingAscii(methodId)),
Value::fromDynamic(m_context, std::move(arguments))
});
auto calls = Value(m_context, result).toJSONString();
m_delegate->callNativeModules(*this, std::move(calls), true);
} catch (...) {
std::throw_with_nested(std::runtime_error("Error calling function: " + moduleId + ":" + methodId));
}
}
void JSCExecutor::invokeCallback(const double callbackId, const folly::dynamic& arguments) throw(JSException) {
auto result = m_invokeCallbackAndReturnFlushedQueueJS->callAsFunction({
JSValueMakeNumber(m_context, callbackId),
Value::fromDynamic(m_context, std::move(arguments))
});
auto calls = Value(m_context, result).toJSONString();
m_delegate->callNativeModules(*this, std::move(calls), true);
void JSCExecutor::invokeCallback(const double callbackId, const folly::dynamic& arguments) {
try {
auto result = m_invokeCallbackAndReturnFlushedQueueJS->callAsFunction({
JSValueMakeNumber(m_context, callbackId),
Value::fromDynamic(m_context, std::move(arguments))
});
auto calls = Value(m_context, result).toJSONString();
m_delegate->callNativeModules(*this, std::move(calls), true);
} catch (...) {
std::throw_with_nested(std::runtime_error(folly::to<std::string>("Error invoking callback.", callbackId)));
}
}
void JSCExecutor::setGlobalVariable(std::string propName, std::unique_ptr<const JSBigString> jsonValue) throw(JSException) {
SystraceSection s("JSCExecutor.setGlobalVariable",
"propName", propName);
void JSCExecutor::setGlobalVariable(std::string propName, std::unique_ptr<const JSBigString> jsonValue) {
try {
SystraceSection s("JSCExecutor.setGlobalVariable",
"propName", propName);
auto globalObject = JSContextGetGlobalObject(m_context);
String jsPropertyName(propName.c_str());
auto globalObject = JSContextGetGlobalObject(m_context);
String jsPropertyName(propName.c_str());
String jsValueJSON = jsStringFromBigString(*jsonValue);
auto valueToInject = JSValueMakeFromJSONString(m_context, jsValueJSON);
String jsValueJSON = jsStringFromBigString(*jsonValue);
auto valueToInject = JSValueMakeFromJSONString(m_context, jsValueJSON);
JSObjectSetProperty(m_context, globalObject, jsPropertyName, valueToInject, 0, NULL);
JSObjectSetProperty(m_context, globalObject, jsPropertyName, valueToInject, 0, NULL);
} catch (...) {
std::throw_with_nested(std::runtime_error("Error setting global variable: " + propName));
}
}
void* JSCExecutor::getJavaScriptContext() {