mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Migrate ReactCxxErrorHandler to Kotlin (#50300)
Summary: Migrate com.facebook.react.bridge.ReactCxxErrorHandler to Kotlin. ## Changelog: [INTERNAL] - Migrate com.facebook.react.bridge.ReactCxxErrorHandler to Kotlin Pull Request resolved: https://github.com/facebook/react-native/pull/50300 Test Plan: ```bash yarn test-android yarn android ``` Reviewed By: huntie Differential Revision: D71964503 Pulled By: javache fbshipit-source-id: f7cb2de8bdeae52680ef2fd72bd052d67e727a1a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
68741d74ee
commit
9ba47b8852
@@ -1133,9 +1133,9 @@ public abstract class com/facebook/react/bridge/ReactContextBaseJavaModule : com
|
||||
protected final fun getCurrentActivity ()Landroid/app/Activity;
|
||||
}
|
||||
|
||||
public class com/facebook/react/bridge/ReactCxxErrorHandler {
|
||||
public fun <init> ()V
|
||||
public static fun setHandleErrorFunc (Ljava/lang/Object;Ljava/lang/reflect/Method;)V
|
||||
public final class com/facebook/react/bridge/ReactCxxErrorHandler {
|
||||
public static final field INSTANCE Lcom/facebook/react/bridge/ReactCxxErrorHandler;
|
||||
public static final fun setHandleErrorFunc (Ljava/lang/Object;Ljava/lang/reflect/Method;)V
|
||||
}
|
||||
|
||||
public final class com/facebook/react/bridge/ReactIgnorableMountingException : java/lang/RuntimeException {
|
||||
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.bridge;
|
||||
|
||||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.react.common.annotations.internal.LegacyArchitecture;
|
||||
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel;
|
||||
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@DoNotStrip
|
||||
@LegacyArchitecture
|
||||
public class ReactCxxErrorHandler {
|
||||
static {
|
||||
LegacyArchitectureLogger.assertWhenLegacyArchitectureMinifyingEnabled(
|
||||
"ReactCxxErrorHandler", LegacyArchitectureLogLevel.WARNING);
|
||||
}
|
||||
|
||||
private static Method mHandleErrorFunc;
|
||||
private static Object mObject;
|
||||
|
||||
@DoNotStrip
|
||||
public static void setHandleErrorFunc(Object object, Method handleErrorFunc) {
|
||||
mObject = object;
|
||||
mHandleErrorFunc = handleErrorFunc;
|
||||
}
|
||||
|
||||
@DoNotStrip
|
||||
// For use from within the C++ JReactCxxErrorHandler
|
||||
private static void handleError(final String message) {
|
||||
if (mHandleErrorFunc != null) {
|
||||
try {
|
||||
Object[] parameters = new Object[1];
|
||||
parameters[0] = new Exception(message);
|
||||
mHandleErrorFunc.invoke(mObject, parameters);
|
||||
} catch (Exception e) {
|
||||
FLog.e("ReactCxxErrorHandler", "Failed to invoke error handler function", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.bridge
|
||||
|
||||
import com.facebook.common.logging.FLog
|
||||
import com.facebook.proguard.annotations.DoNotStrip
|
||||
import com.facebook.react.common.annotations.internal.LegacyArchitecture
|
||||
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel
|
||||
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger
|
||||
import java.lang.reflect.Method
|
||||
|
||||
@DoNotStrip
|
||||
@LegacyArchitecture
|
||||
public object ReactCxxErrorHandler {
|
||||
init {
|
||||
LegacyArchitectureLogger.assertWhenLegacyArchitectureMinifyingEnabled(
|
||||
"ReactCxxErrorHandler", LegacyArchitectureLogLevel.WARNING)
|
||||
}
|
||||
|
||||
private var handleErrorFunc: Method? = null
|
||||
private var handlerObject: Any? = null
|
||||
|
||||
@DoNotStrip
|
||||
@JvmStatic
|
||||
public fun setHandleErrorFunc(handlerObject: Any?, handleErrorFunc: Method?) {
|
||||
this.handlerObject = handlerObject
|
||||
this.handleErrorFunc = handleErrorFunc
|
||||
}
|
||||
|
||||
@DoNotStrip
|
||||
@JvmStatic
|
||||
// For use from within the C++ JReactCxxErrorHandler
|
||||
private fun handleError(message: String) {
|
||||
handleErrorFunc?.let {
|
||||
try {
|
||||
val parameters = arrayOf<Any>(Exception(message))
|
||||
it.invoke(handlerObject, parameters)
|
||||
} catch (e: Exception) {
|
||||
FLog.e("ReactCxxErrorHandler", "Failed to invoke error handler function", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user