Skip to content

Commit

Permalink
Categorize SoftAssertions
Browse files Browse the repository at this point in the history
Summary:
Extract a constant for SoftAssertions so they can be logged appropriately

Changelog: [Internal]

Reviewed By: makovkastar

Differential Revision: D67296589
  • Loading branch information
Thomas Nardone authored and facebook-github-bot committed Dec 17, 2024
1 parent 5c789c3 commit 2ee5a0e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
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 @@ -1427,6 +1427,7 @@ public final class com/facebook/react/bridge/ReactSoftExceptionLogger$Categories
public static final field INSTANCE Lcom/facebook/react/bridge/ReactSoftExceptionLogger$Categories;
public static final field RVG_IS_VIEW_CLIPPED Ljava/lang/String;
public static final field RVG_ON_VIEW_REMOVED Ljava/lang/String;
public static final field SOFT_ASSERTIONS Ljava/lang/String;
}

public abstract interface class com/facebook/react/bridge/ReactSoftExceptionLogger$ReactSoftExceptionListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public object ReactSoftExceptionLogger {
public object Categories {
public const val RVG_IS_VIEW_CLIPPED: String = "ReactViewGroup.isViewClipped"
public const val RVG_ON_VIEW_REMOVED: String = "ReactViewGroup.onViewRemoved"
public const val SOFT_ASSERTIONS: String = "SoftAssertions"
}

// Use a list instead of a set here because we expect the number of listeners
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

package com.facebook.react.bridge

import com.facebook.react.bridge.ReactSoftExceptionLogger.Categories.SOFT_ASSERTIONS

/**
* Utility class to make assertions that should not hard-crash the app but instead be handled by the
* Catalyst app [JSExceptionHandler]. See the javadoc on that class for more information about our
Expand All @@ -23,7 +25,7 @@ public object SoftAssertions {
*/
@JvmStatic
public fun assertUnreachable(message: String): Unit {
ReactSoftExceptionLogger.logSoftException("SoftAssertions", AssertionException(message))
ReactSoftExceptionLogger.logSoftException(SOFT_ASSERTIONS, AssertionException(message))
}

/**
Expand All @@ -34,7 +36,7 @@ public object SoftAssertions {
@JvmStatic
public fun assertCondition(condition: Boolean, message: String): Unit {
if (!condition) {
ReactSoftExceptionLogger.logSoftException("SoftAssertions", AssertionException(message))
ReactSoftExceptionLogger.logSoftException(SOFT_ASSERTIONS, AssertionException(message))
}
}

Expand All @@ -46,7 +48,7 @@ public object SoftAssertions {
public fun <T> assertNotNull(instance: T?): T? {
if (instance == null) {
ReactSoftExceptionLogger.logSoftException(
"SoftAssertions", AssertionException("Expected object to not be null!"))
SOFT_ASSERTIONS, AssertionException("Expected object to not be null!"))
}
return instance
}
Expand Down

0 comments on commit 2ee5a0e

Please sign in to comment.