Skip to content

Commit 098454d

Browse files
Keion Anvaripourfacebook-github-bot
authored andcommitted
Expose JSExceptionHandler to ReactNativeHost (#44172)
Summary: Pull Request resolved: #44172 Changelog: [Android][Added] Option to set a custom JSExceptionHandler instance Reviewed By: javache Differential Revision: D56382090 fbshipit-source-id: 69ad72ee34f1c9f636d95035d0463c5344cb4a37
1 parent 00055f8 commit 098454d

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ public abstract class com/facebook/react/ReactNativeHost {
318318
protected fun getDevSupportManagerFactory ()Lcom/facebook/react/devsupport/DevSupportManagerFactory;
319319
protected fun getJSBundleFile ()Ljava/lang/String;
320320
protected fun getJSEngineResolutionAlgorithm ()Lcom/facebook/react/JSEngineResolutionAlgorithm;
321+
protected fun getJSExceptionHandler ()Lcom/facebook/react/bridge/JSExceptionHandler;
321322
protected fun getJSMainModuleName ()Ljava/lang/String;
322323
protected fun getJavaScriptExecutorFactory ()Lcom/facebook/react/bridge/JavaScriptExecutorFactory;
323324
public fun getLazyViewManagersEnabled ()Z

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public ReactInstanceManagerBuilder setInitialLifecycleState(
258258
* DevSupportManager} will be used, which shows a redbox in dev mode and rethrows (crashes the
259259
* app) in prod mode.
260260
*/
261-
public ReactInstanceManagerBuilder setJSExceptionHandler(JSExceptionHandler handler) {
261+
public ReactInstanceManagerBuilder setJSExceptionHandler(@Nullable JSExceptionHandler handler) {
262262
mJSExceptionHandler = handler;
263263
return this;
264264
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import android.app.Application;
1111
import androidx.annotation.Nullable;
1212
import com.facebook.infer.annotation.Assertions;
13+
import com.facebook.react.bridge.JSExceptionHandler;
1314
import com.facebook.react.bridge.JavaScriptExecutorFactory;
1415
import com.facebook.react.bridge.ReactMarker;
1516
import com.facebook.react.bridge.ReactMarkerConstants;
@@ -89,6 +90,7 @@ protected ReactInstanceManagerBuilder getBaseReactInstanceManagerBuilder() {
8990
.setDevLoadingViewManager(getDevLoadingViewManager())
9091
.setRequireActivity(getShouldRequireActivity())
9192
.setSurfaceDelegateFactory(getSurfaceDelegateFactory())
93+
.setJSExceptionHandler(getJSExceptionHandler())
9294
.setLazyViewManagersEnabled(getLazyViewManagersEnabled())
9395
.setRedBoxHandler(getRedBoxHandler())
9496
.setJavaScriptExecutorFactory(getJavaScriptExecutorFactory())
@@ -118,6 +120,10 @@ protected ReactInstanceManagerBuilder getBaseReactInstanceManagerBuilder() {
118120
return null;
119121
}
120122

123+
protected @Nullable JSExceptionHandler getJSExceptionHandler() {
124+
return null;
125+
}
126+
121127
/** Get the {@link JavaScriptExecutorFactory}. Override this to use a custom Executor. */
122128
protected @Nullable JavaScriptExecutorFactory getJavaScriptExecutorFactory() {
123129
return null;

0 commit comments

Comments
 (0)