Adding JS hierarchy information when a StackOverflowException is thrown in Dev mode

Reviewed By: achen1

Differential Revision: D6716309

fbshipit-source-id: 23458cd126d13fec3aa9c09420f7cdd230ec8dd0
This commit is contained in:
David Vacca
2018-01-19 12:34:23 -08:00
committed by Facebook Github Bot
parent e8893a021f
commit 4d3519cc6a
11 changed files with 237 additions and 24 deletions

View File

@@ -210,7 +210,7 @@ public class ReactRootView extends SizeMonitoringFrameLayout
} catch (StackOverflowError e) {
// Adding special exception management for StackOverflowError for logging purposes.
// This will be removed in the future.
handleException(new IllegalViewOperationException("StackOverflowError", e));
handleException(e);
}
}
@@ -510,12 +510,19 @@ public class ReactRootView extends SizeMonitoringFrameLayout
}
@Override
public void handleException(Exception e) {
if (mReactInstanceManager != null && mReactInstanceManager.getCurrentReactContext() != null) {
mReactInstanceManager.getCurrentReactContext().handleException(e);
} else {
throw new RuntimeException(e);
public void handleException(Throwable t) {
if (mReactInstanceManager == null
|| mReactInstanceManager.getCurrentReactContext() == null) {
throw new RuntimeException(t);
}
// Adding special exception management for StackOverflowError for logging purposes.
// This will be removed in the future.
Exception e = (t instanceof StackOverflowError) ?
new IllegalViewOperationException("StackOverflowException", this, t) :
t instanceof Exception ? (Exception) t : new RuntimeException(t);
mReactInstanceManager.getCurrentReactContext().handleException(e);
}
@Nullable