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:
committed by
Facebook Github Bot
parent
f0722287be
commit
e594176401
@@ -198,6 +198,11 @@ class JFlipperPlugin : public jni::JavaClass<JFlipperPlugin> {
|
|||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return "";
|
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));
|
method(self(), JFlipperConnectionImpl::newObjectCxxArgs(conn));
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
|
} catch (const std::exception* e) {
|
||||||
|
if (e) {
|
||||||
|
handleException(*e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,6 +228,10 @@ class JFlipperPlugin : public jni::JavaClass<JFlipperPlugin> {
|
|||||||
method(self());
|
method(self());
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
handleException(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) {
|
} catch (const std::exception& e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return false;
|
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());
|
method(self());
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
|
} catch (const std::exception* e) {
|
||||||
|
if (e) {
|
||||||
|
handleException(*e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void onStepStarted(std::string step) {
|
void onStepStarted(std::string step) {
|
||||||
@@ -254,6 +276,10 @@ class JFlipperStateUpdateListener : public jni::JavaClass<JFlipperStateUpdateLis
|
|||||||
method(self(), step);
|
method(self(), step);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
|
} catch (const std::exception* e) {
|
||||||
|
if (e) {
|
||||||
|
handleException(*e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void onStepSuccess(std::string step) {
|
void onStepSuccess(std::string step) {
|
||||||
@@ -263,6 +289,10 @@ class JFlipperStateUpdateListener : public jni::JavaClass<JFlipperStateUpdateLis
|
|||||||
method(self(), step);
|
method(self(), step);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
|
} catch (const std::exception* e) {
|
||||||
|
if (e) {
|
||||||
|
handleException(*e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void onStepFailed(std::string step, std::string errorMessage) {
|
void onStepFailed(std::string step, std::string errorMessage) {
|
||||||
@@ -273,6 +303,10 @@ class JFlipperStateUpdateListener : public jni::JavaClass<JFlipperStateUpdateLis
|
|||||||
method(self(), step, errorMessage);
|
method(self(), step, errorMessage);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
handleException(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();
|
FlipperClient::instance()->start();
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
handleException(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();
|
FlipperClient::instance()->stop();
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
handleException(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);
|
FlipperClient::instance()->addPlugin(wrapper);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
handleException(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()));
|
client->removePlugin(client->getPlugin(plugin->identifier()));
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
handleException(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);
|
client->setStateListener(mStateListener);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
handleException(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);
|
client->setStateListener(nullptr);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
handleException(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) {
|
} catch (const std::exception& e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return "";
|
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) {
|
} catch (const std::exception& e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return nullptr;
|
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) {
|
} catch (const std::exception& e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
} catch (const std::exception* e) {
|
||||||
|
if (e) {
|
||||||
|
handleException(*e);
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user