Remove HasJavascriptExceptionMetadata interface (#45440)

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

We only have one type of JavaScriptException anymore, so this can be simplified.

Changelog: [Android][Removed] Removed HasJavascriptExceptionMetadata as a marker interface. Use JavascriptExecption directly

Differential Revision: D57379390

fbshipit-source-id: a088834fddb156ceed5ccc8010d3c4acd365bf29
This commit is contained in:
Pieter De Baets
2024-07-15 08:23:44 -07:00
committed by Facebook GitHub Bot
parent b7e70968fa
commit cb00ca954d
6 changed files with 12 additions and 44 deletions
@@ -1709,14 +1709,10 @@ public class com/facebook/react/common/DebugServerException : java/lang/RuntimeE
public static fun parse (Ljava/lang/String;Ljava/lang/String;)Lcom/facebook/react/common/DebugServerException;
}
public abstract interface class com/facebook/react/common/HasJavascriptExceptionMetadata {
public abstract fun getExtraDataAsJson ()Ljava/lang/String;
}
public class com/facebook/react/common/JavascriptException : java/lang/RuntimeException, com/facebook/react/common/HasJavascriptExceptionMetadata {
public class com/facebook/react/common/JavascriptException : java/lang/RuntimeException {
public fun <init> (Ljava/lang/String;)V
public fun getExtraDataAsJson ()Ljava/lang/String;
public final fun setExtraDataAsJson (Ljava/lang/String;)Lcom/facebook/react/common/JavascriptException;
public final fun getExtraDataAsJson ()Ljava/lang/String;
public final fun setExtraDataAsJson (Ljava/lang/String;)V
}
public final class com/facebook/react/common/LifecycleState : java/lang/Enum {
@@ -7,6 +7,8 @@
package com.facebook.react.bridge;
import javax.annotation.Nullable;
/**
* Extends RuntimeException so that it may be caught by a {@link ReactSoftExceptionListener}. Any
* {@link ReactSoftExceptionListener} that catches a ReactNoCrashSoftException should log it only
@@ -21,7 +23,7 @@ public class ReactNoCrashSoftException extends RuntimeException {
super(e);
}
public ReactNoCrashSoftException(String m, Throwable e) {
public ReactNoCrashSoftException(String m, @Nullable Throwable e) {
super(m, e);
}
}
@@ -1,17 +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.common;
import javax.annotation.Nullable;
/** A JS exception carrying metadata. */
public interface HasJavascriptExceptionMetadata {
@Nullable
String getExtraDataAsJson();
}
@@ -14,14 +14,6 @@ import com.facebook.proguard.annotations.DoNotStrip
* to developers in a redbox.
*/
@DoNotStrip
public open class JavascriptException(jsStackTrace: String) :
RuntimeException(jsStackTrace), HasJavascriptExceptionMetadata {
private var extraDataAsJson: String? = null
override fun getExtraDataAsJson(): String? = extraDataAsJson
public fun setExtraDataAsJson(extraDataAsJson: String?): JavascriptException {
this.extraDataAsJson = extraDataAsJson
return this
}
public open class JavascriptException(jsStackTrace: String) : RuntimeException(jsStackTrace) {
public var extraDataAsJson: String? = null
}
@@ -62,8 +62,9 @@ public class ExceptionsManagerModule extends NativeExceptionsManagerSpec {
String extraDataAsJson = ExceptionDataHelper.getExtraDataAsJson(data);
if (isFatal) {
throw new JavascriptException(JSStackTrace.format(message, stack))
.setExtraDataAsJson(extraDataAsJson);
JavascriptException ex = new JavascriptException(JSStackTrace.format(message, stack));
ex.setExtraDataAsJson(extraDataAsJson);
throw ex;
} else {
FLog.e(ReactConstants.TAG, JSStackTrace.format(message, stack));
if (extraDataAsJson != null) {
@@ -924,14 +924,8 @@ public class ReactHostImpl implements ReactHost {
String callingMethod, String message, @Nullable Throwable throwable) {
final String method = "raiseSoftException(" + callingMethod + ")";
log(method, message);
if (throwable != null) {
ReactSoftExceptionLogger.logSoftException(
TAG, new ReactNoCrashSoftException(method + ": " + message, throwable));
return;
}
ReactSoftExceptionLogger.logSoftException(
TAG, new ReactNoCrashSoftException(method + ": " + message));
TAG, new ReactNoCrashSoftException(method + ": " + message, throwable));
}
private Executor getDefaultReactInstanceExecutor() {