Remove some throw specifications
Reviewed By: mhorowitz Differential Revision: D3588394 fbshipit-source-id: 56e24f28b1f4eba2564007b395afcac6fa5cb209
This commit is contained in:
parent
20f48debb6
commit
e7fba4c123
|
@ -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() {
|
||||
|
|
|
@ -70,13 +70,13 @@ public:
|
|||
virtual void callFunction(
|
||||
const std::string& moduleId,
|
||||
const std::string& methodId,
|
||||
const folly::dynamic& arguments) throw(JSException) override;
|
||||
const folly::dynamic& arguments) override;
|
||||
virtual void invokeCallback(
|
||||
const double callbackId,
|
||||
const folly::dynamic& arguments) throw(JSException) override;
|
||||
const folly::dynamic& arguments) override;
|
||||
virtual void setGlobalVariable(
|
||||
std::string propName,
|
||||
std::unique_ptr<const JSBigString> jsonValue) throw(JSException) override;
|
||||
std::unique_ptr<const JSBigString> jsonValue) override;
|
||||
virtual void* getJavaScriptContext() override;
|
||||
virtual bool supportsProfiling() override;
|
||||
virtual void startProfiler(const std::string &titleString) override;
|
||||
|
@ -117,7 +117,7 @@ private:
|
|||
void initOnJSVMThread() throw(JSException);
|
||||
void terminateOnJSVMThread();
|
||||
void bindBridge() throw(JSException);
|
||||
void flush() throw(JSException);
|
||||
void flush();
|
||||
void flushQueueImmediate(std::string queueJSON);
|
||||
void loadModule(uint32_t moduleId);
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ JSContextRef Value::context() const {
|
|||
return m_context;
|
||||
}
|
||||
|
||||
std::string Value::toJSONString(unsigned indent) const throw(JSException) {
|
||||
std::string Value::toJSONString(unsigned indent) const {
|
||||
JSValueRef exn;
|
||||
auto stringToAdopt = JSValueCreateJSONString(m_context, m_value, indent, &exn);
|
||||
if (stringToAdopt == nullptr) {
|
||||
|
@ -46,7 +46,7 @@ std::string Value::toJSONString(unsigned indent) const throw(JSException) {
|
|||
}
|
||||
|
||||
/* static */
|
||||
Value Value::fromJSON(JSContextRef ctx, const String& json) throw(JSException) {
|
||||
Value Value::fromJSON(JSContextRef ctx, const String& json) {
|
||||
auto result = JSValueMakeFromJSONString(ctx, json);
|
||||
if (!result) {
|
||||
throwJSExecutionException("Failed to create String from JSON");
|
||||
|
|
|
@ -282,8 +282,8 @@ public:
|
|||
return String::adopt(JSValueToStringCopy(context(), m_value, nullptr));
|
||||
}
|
||||
|
||||
std::string toJSONString(unsigned indent = 0) const throw(JSException);
|
||||
static Value fromJSON(JSContextRef ctx, const String& json) throw(JSException);
|
||||
std::string toJSONString(unsigned indent = 0) const;
|
||||
static Value fromJSON(JSContextRef ctx, const String& json);
|
||||
static JSValueRef fromDynamic(JSContextRef ctx, const folly::dynamic& value);
|
||||
JSContextRef context() const;
|
||||
protected:
|
||||
|
|
Loading…
Reference in New Issue