Skip to content

Commit

Permalink
Expose JSExceptionHandler to ReactNativeHost (facebook#44172)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#44172

Changelog: [Android][Added] Option to set a custom JSExceptionHandler instance

Reviewed By: javache

Differential Revision: D56382090

fbshipit-source-id: 69ad72ee34f1c9f636d95035d0463c5344cb4a37
  • Loading branch information
Keion Anvaripour authored and kosmydel committed May 6, 2024
1 parent 41108a4 commit 13d74c8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ public abstract class com/facebook/react/ReactNativeHost {
protected fun getDevSupportManagerFactory ()Lcom/facebook/react/devsupport/DevSupportManagerFactory;
protected fun getJSBundleFile ()Ljava/lang/String;
protected fun getJSEngineResolutionAlgorithm ()Lcom/facebook/react/JSEngineResolutionAlgorithm;
protected fun getJSExceptionHandler ()Lcom/facebook/react/bridge/JSExceptionHandler;
protected fun getJSMainModuleName ()Ljava/lang/String;
protected fun getJavaScriptExecutorFactory ()Lcom/facebook/react/bridge/JavaScriptExecutorFactory;
public fun getLazyViewManagersEnabled ()Z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public ReactInstanceManagerBuilder setInitialLifecycleState(
* DevSupportManager} will be used, which shows a redbox in dev mode and rethrows (crashes the
* app) in prod mode.
*/
public ReactInstanceManagerBuilder setJSExceptionHandler(JSExceptionHandler handler) {
public ReactInstanceManagerBuilder setJSExceptionHandler(@Nullable JSExceptionHandler handler) {
mJSExceptionHandler = handler;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.app.Application;
import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.JSExceptionHandler;
import com.facebook.react.bridge.JavaScriptExecutorFactory;
import com.facebook.react.bridge.ReactMarker;
import com.facebook.react.bridge.ReactMarkerConstants;
Expand Down Expand Up @@ -89,6 +90,7 @@ protected ReactInstanceManagerBuilder getBaseReactInstanceManagerBuilder() {
.setDevLoadingViewManager(getDevLoadingViewManager())
.setRequireActivity(getShouldRequireActivity())
.setSurfaceDelegateFactory(getSurfaceDelegateFactory())
.setJSExceptionHandler(getJSExceptionHandler())
.setLazyViewManagersEnabled(getLazyViewManagersEnabled())
.setRedBoxHandler(getRedBoxHandler())
.setJavaScriptExecutorFactory(getJavaScriptExecutorFactory())
Expand Down Expand Up @@ -118,6 +120,10 @@ protected ReactInstanceManagerBuilder getBaseReactInstanceManagerBuilder() {
return null;
}

protected @Nullable JSExceptionHandler getJSExceptionHandler() {
return null;
}

/** Get the {@link JavaScriptExecutorFactory}. Override this to use a custom Executor. */
protected @Nullable JavaScriptExecutorFactory getJavaScriptExecutorFactory() {
return null;
Expand Down

0 comments on commit 13d74c8

Please sign in to comment.