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 коммит произвёл Facebook Github Bot 3
Родитель 20f48debb6
Коммит e7fba4c123
4 изменённых файлов: 56 добавлений и 34 удалений

Просмотреть файл

@ -340,42 +340,64 @@ void JSCExecutor::bindBridge() throw(JSException) {
m_flushedQueueJS = batchedBridge.getProperty("flushedQueue").asObject(); m_flushedQueueJS = batchedBridge.getProperty("flushedQueue").asObject();
} }
void JSCExecutor::flush() throw(JSException) { void JSCExecutor::flush() {
auto result = m_flushedQueueJS->callAsFunction({}); auto result = m_flushedQueueJS->callAsFunction({});
auto calls = Value(m_context, result).toJSONString(); try {
m_delegate->callNativeModules(*this, std::move(calls), true); 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) { void JSCExecutor::callFunction(const std::string& moduleId, const std::string& methodId, const folly::dynamic& arguments) {
auto result = m_callFunctionReturnFlushedQueueJS->callAsFunction({ try {
Value(m_context, String::createExpectingAscii(moduleId)), auto result = m_callFunctionReturnFlushedQueueJS->callAsFunction({
Value(m_context, String::createExpectingAscii(methodId)), Value(m_context, String::createExpectingAscii(moduleId)),
Value::fromDynamic(m_context, std::move(arguments)) 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); 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) { void JSCExecutor::invokeCallback(const double callbackId, const folly::dynamic& arguments) {
auto result = m_invokeCallbackAndReturnFlushedQueueJS->callAsFunction({ try {
JSValueMakeNumber(m_context, callbackId), auto result = m_invokeCallbackAndReturnFlushedQueueJS->callAsFunction({
Value::fromDynamic(m_context, std::move(arguments)) 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); 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) { void JSCExecutor::setGlobalVariable(std::string propName, std::unique_ptr<const JSBigString> jsonValue) {
SystraceSection s("JSCExecutor.setGlobalVariable", try {
"propName", propName); SystraceSection s("JSCExecutor.setGlobalVariable",
"propName", propName);
auto globalObject = JSContextGetGlobalObject(m_context); auto globalObject = JSContextGetGlobalObject(m_context);
String jsPropertyName(propName.c_str()); String jsPropertyName(propName.c_str());
String jsValueJSON = jsStringFromBigString(*jsonValue); String jsValueJSON = jsStringFromBigString(*jsonValue);
auto valueToInject = JSValueMakeFromJSONString(m_context, jsValueJSON); 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() { void* JSCExecutor::getJavaScriptContext() {

Просмотреть файл

@ -70,13 +70,13 @@ public:
virtual void callFunction( virtual void callFunction(
const std::string& moduleId, const std::string& moduleId,
const std::string& methodId, const std::string& methodId,
const folly::dynamic& arguments) throw(JSException) override; const folly::dynamic& arguments) override;
virtual void invokeCallback( virtual void invokeCallback(
const double callbackId, const double callbackId,
const folly::dynamic& arguments) throw(JSException) override; const folly::dynamic& arguments) override;
virtual void setGlobalVariable( virtual void setGlobalVariable(
std::string propName, std::string propName,
std::unique_ptr<const JSBigString> jsonValue) throw(JSException) override; std::unique_ptr<const JSBigString> jsonValue) override;
virtual void* getJavaScriptContext() override; virtual void* getJavaScriptContext() override;
virtual bool supportsProfiling() override; virtual bool supportsProfiling() override;
virtual void startProfiler(const std::string &titleString) override; virtual void startProfiler(const std::string &titleString) override;
@ -117,7 +117,7 @@ private:
void initOnJSVMThread() throw(JSException); void initOnJSVMThread() throw(JSException);
void terminateOnJSVMThread(); void terminateOnJSVMThread();
void bindBridge() throw(JSException); void bindBridge() throw(JSException);
void flush() throw(JSException); void flush();
void flushQueueImmediate(std::string queueJSON); void flushQueueImmediate(std::string queueJSON);
void loadModule(uint32_t moduleId); void loadModule(uint32_t moduleId);

Просмотреть файл

@ -35,7 +35,7 @@ JSContextRef Value::context() const {
return m_context; return m_context;
} }
std::string Value::toJSONString(unsigned indent) const throw(JSException) { std::string Value::toJSONString(unsigned indent) const {
JSValueRef exn; JSValueRef exn;
auto stringToAdopt = JSValueCreateJSONString(m_context, m_value, indent, &exn); auto stringToAdopt = JSValueCreateJSONString(m_context, m_value, indent, &exn);
if (stringToAdopt == nullptr) { if (stringToAdopt == nullptr) {
@ -46,7 +46,7 @@ std::string Value::toJSONString(unsigned indent) const throw(JSException) {
} }
/* static */ /* static */
Value Value::fromJSON(JSContextRef ctx, const String& json) throw(JSException) { Value Value::fromJSON(JSContextRef ctx, const String& json) {
auto result = JSValueMakeFromJSONString(ctx, json); auto result = JSValueMakeFromJSONString(ctx, json);
if (!result) { if (!result) {
throwJSExecutionException("Failed to create String from JSON"); throwJSExecutionException("Failed to create String from JSON");

Просмотреть файл

@ -282,8 +282,8 @@ public:
return String::adopt(JSValueToStringCopy(context(), m_value, nullptr)); return String::adopt(JSValueToStringCopy(context(), m_value, nullptr));
} }
std::string toJSONString(unsigned indent = 0) const throw(JSException); std::string toJSONString(unsigned indent = 0) const;
static Value fromJSON(JSContextRef ctx, const String& json) throw(JSException); static Value fromJSON(JSContextRef ctx, const String& json);
static JSValueRef fromDynamic(JSContextRef ctx, const folly::dynamic& value); static JSValueRef fromDynamic(JSContextRef ctx, const folly::dynamic& value);
JSContextRef context() const; JSContextRef context() const;
protected: protected: