Skip to content

Commit 5a01291

Browse files
Thomas Nardonefacebook-github-bot
Thomas Nardone
authored andcommitted
Categorize SoftAssertions (#48306)
Summary: Pull Request resolved: #48306 Extract a constant for SoftAssertions so they can be logged appropriately Changelog: [Internal] Reviewed By: makovkastar Differential Revision: D67296589 fbshipit-source-id: c8823fd5dfa09a771bb8fbf498edb8d9264f053f
1 parent 0ceb0b3 commit 5a01291

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,7 @@ public final class com/facebook/react/bridge/ReactSoftExceptionLogger$Categories
14271427
public static final field INSTANCE Lcom/facebook/react/bridge/ReactSoftExceptionLogger$Categories;
14281428
public static final field RVG_IS_VIEW_CLIPPED Ljava/lang/String;
14291429
public static final field RVG_ON_VIEW_REMOVED Ljava/lang/String;
1430+
public static final field SOFT_ASSERTIONS Ljava/lang/String;
14301431
}
14311432

14321433
public abstract interface class com/facebook/react/bridge/ReactSoftExceptionLogger$ReactSoftExceptionListener {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactSoftExceptionLogger.kt

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public object ReactSoftExceptionLogger {
1818
public object Categories {
1919
public const val RVG_IS_VIEW_CLIPPED: String = "ReactViewGroup.isViewClipped"
2020
public const val RVG_ON_VIEW_REMOVED: String = "ReactViewGroup.onViewRemoved"
21+
public const val SOFT_ASSERTIONS: String = "SoftAssertions"
2122
}
2223

2324
// Use a list instead of a set here because we expect the number of listeners

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/SoftAssertions.kt

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
package com.facebook.react.bridge
99

10+
import com.facebook.react.bridge.ReactSoftExceptionLogger.Categories.SOFT_ASSERTIONS
11+
1012
/**
1113
* Utility class to make assertions that should not hard-crash the app but instead be handled by the
1214
* Catalyst app [JSExceptionHandler]. See the javadoc on that class for more information about our
@@ -23,7 +25,7 @@ public object SoftAssertions {
2325
*/
2426
@JvmStatic
2527
public fun assertUnreachable(message: String): Unit {
26-
ReactSoftExceptionLogger.logSoftException("SoftAssertions", AssertionException(message))
28+
ReactSoftExceptionLogger.logSoftException(SOFT_ASSERTIONS, AssertionException(message))
2729
}
2830

2931
/**
@@ -34,7 +36,7 @@ public object SoftAssertions {
3436
@JvmStatic
3537
public fun assertCondition(condition: Boolean, message: String): Unit {
3638
if (!condition) {
37-
ReactSoftExceptionLogger.logSoftException("SoftAssertions", AssertionException(message))
39+
ReactSoftExceptionLogger.logSoftException(SOFT_ASSERTIONS, AssertionException(message))
3840
}
3941
}
4042

@@ -46,7 +48,7 @@ public object SoftAssertions {
4648
public fun <T> assertNotNull(instance: T?): T? {
4749
if (instance == null) {
4850
ReactSoftExceptionLogger.logSoftException(
49-
"SoftAssertions", AssertionException("Expected object to not be null!"))
51+
SOFT_ASSERTIONS, AssertionException("Expected object to not be null!"))
5052
}
5153
return instance
5254
}

0 commit comments

Comments
 (0)