Handle any exception pointers at top level

Summary: If a plugin thows an exception pointer instead of by value, we should capture it and stop the app from crashing.

Reviewed By: passy

Differential Revision: D14243644

fbshipit-source-id: a2e5dde2b36c430355552e3305634baa5913b703
This commit is contained in:
John Knox
2019-02-28 05:36:23 -08:00
committed by Facebook Github Bot
parent f0722287be
commit e594176401

View File

@@ -198,6 +198,11 @@ class JFlipperPlugin : public jni::JavaClass<JFlipperPlugin> {
} catch (const std::exception& e) {
handleException(e);
return "";
} catch (const std::exception* e) {
if (e) {
handleException(*e);
}
return "";
}
}
@@ -210,6 +215,10 @@ class JFlipperPlugin : public jni::JavaClass<JFlipperPlugin> {
method(self(), JFlipperConnectionImpl::newObjectCxxArgs(conn));
} catch (const std::exception& e) {
handleException(e);
} catch (const std::exception* e) {
if (e) {
handleException(*e);
}
}
}
@@ -219,6 +228,10 @@ class JFlipperPlugin : public jni::JavaClass<JFlipperPlugin> {
method(self());
} catch (const std::exception& e) {
handleException(e);
} catch (const std::exception* e) {
if (e) {
handleException(*e);
}
}
}
@@ -230,6 +243,11 @@ class JFlipperPlugin : public jni::JavaClass<JFlipperPlugin> {
} catch (const std::exception& e) {
handleException(e);
return false;
} catch (const std::exception* e) {
if (e) {
handleException(*e);
}
return false;
}
}
};
@@ -245,6 +263,10 @@ class JFlipperStateUpdateListener : public jni::JavaClass<JFlipperStateUpdateLis
method(self());
} catch (const std::exception& e) {
handleException(e);
} catch (const std::exception* e) {
if (e) {
handleException(*e);
}
}
}
void onStepStarted(std::string step) {
@@ -254,6 +276,10 @@ class JFlipperStateUpdateListener : public jni::JavaClass<JFlipperStateUpdateLis
method(self(), step);
} catch (const std::exception& e) {
handleException(e);
} catch (const std::exception* e) {
if (e) {
handleException(*e);
}
}
}
void onStepSuccess(std::string step) {
@@ -263,6 +289,10 @@ class JFlipperStateUpdateListener : public jni::JavaClass<JFlipperStateUpdateLis
method(self(), step);
} catch (const std::exception& e) {
handleException(e);
} catch (const std::exception* e) {
if (e) {
handleException(*e);
}
}
}
void onStepFailed(std::string step, std::string errorMessage) {
@@ -273,6 +303,10 @@ class JFlipperStateUpdateListener : public jni::JavaClass<JFlipperStateUpdateLis
method(self(), step, errorMessage);
} catch (const std::exception& e) {
handleException(e);
} catch (const std::exception* e) {
if (e) {
handleException(*e);
}
}
}
};
@@ -359,6 +393,10 @@ class JFlipperClient : public jni::HybridClass<JFlipperClient> {
FlipperClient::instance()->start();
} catch (const std::exception& e) {
handleException(e);
} catch (const std::exception* e) {
if (e) {
handleException(*e);
}
}
}
@@ -367,6 +405,10 @@ class JFlipperClient : public jni::HybridClass<JFlipperClient> {
FlipperClient::instance()->stop();
} catch (const std::exception& e) {
handleException(e);
} catch (const std::exception* e) {
if (e) {
handleException(*e);
}
}
}
@@ -377,6 +419,10 @@ class JFlipperClient : public jni::HybridClass<JFlipperClient> {
FlipperClient::instance()->addPlugin(wrapper);
} catch (const std::exception& e) {
handleException(e);
} catch (const std::exception* e) {
if (e) {
handleException(*e);
}
}
}
@@ -386,6 +432,10 @@ class JFlipperClient : public jni::HybridClass<JFlipperClient> {
client->removePlugin(client->getPlugin(plugin->identifier()));
} catch (const std::exception& e) {
handleException(e);
} catch (const std::exception* e) {
if (e) {
handleException(*e);
}
}
}
@@ -397,6 +447,10 @@ class JFlipperClient : public jni::HybridClass<JFlipperClient> {
client->setStateListener(mStateListener);
} catch (const std::exception& e) {
handleException(e);
} catch (const std::exception* e) {
if (e) {
handleException(*e);
}
}
}
@@ -407,6 +461,10 @@ class JFlipperClient : public jni::HybridClass<JFlipperClient> {
client->setStateListener(nullptr);
} catch (const std::exception& e) {
handleException(e);
} catch (const std::exception* e) {
if (e) {
handleException(*e);
}
}
}
@@ -416,6 +474,11 @@ class JFlipperClient : public jni::HybridClass<JFlipperClient> {
} catch (const std::exception& e) {
handleException(e);
return "";
} catch (const std::exception* e) {
if (e) {
handleException(*e);
}
return "";
}
}
@@ -442,6 +505,11 @@ class JFlipperClient : public jni::HybridClass<JFlipperClient> {
} catch (const std::exception& e) {
handleException(e);
return nullptr;
} catch (const std::exception* e) {
if (e) {
handleException(*e);
}
return nullptr;
}
}
@@ -457,6 +525,11 @@ class JFlipperClient : public jni::HybridClass<JFlipperClient> {
} catch (const std::exception& e) {
handleException(e);
return nullptr;
} catch (const std::exception* e) {
if (e) {
handleException(*e);
}
return nullptr;
}
}