Rethrow original exception in DefaultReactHostDelegate (#46016)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46016

Wrapping the JavaScriptException with a RuntimException means we lose JS specific metadata on the top-level exceptions, and can break categorization in crash-reporting tools.

We could also use the same logic as [DefaultJSExceptionHandler](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/DefaultJSExceptionHandler.java) but that doesn't seem to be required for Kotlin.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D61261515

fbshipit-source-id: fa85c8818834905759cbc984ea3c45403eb87e8c
This commit is contained in:
Pieter De Baets
2024-08-14 05:33:41 -07:00
committed by Facebook GitHub Bot
parent 5b761ff15c
commit 59c1adbfdb
@@ -45,9 +45,7 @@ public class DefaultReactHostDelegate(
override val jsRuntimeFactory: JSRuntimeFactory = HermesInstance(),
override val bindingsInstaller: BindingsInstaller? = null,
private val reactNativeConfig: ReactNativeConfig = ReactNativeConfig.DEFAULT_CONFIG,
private val exceptionHandler: (Exception) -> Unit = {
throw RuntimeException("Unrecoverable React Native error", it)
},
private val exceptionHandler: (Exception) -> Unit = { throw it },
override val turboModuleManagerDelegateBuilder: ReactPackageTurboModuleManagerDelegate.Builder
) : ReactHostDelegate {