-
public class SoftAssertions
Utility class to make assertions that should not hard-crash the app but instead be handled by the Catalyst app NativeModuleCallExceptionHandler. See the javadoc on that class for more information about our opinion on when these assertions should be used as opposed to assertions that might throw AssertionError Throwables that will cause the app to hard crash.
-
-
Method Summary
Modifier and Type Method Description static void
assertUnreachable(String message)
Throw AssertionException with a given message. static void
assertCondition(boolean condition, String message)
Asserts the given condition, throwing an AssertionException if the condition doesn'thold. static <T> T
assertNotNull(@Nullable() T instance)
Asserts that the given Object isn't null, throwing an AssertionException if it was.This logs an assertion with ReactSoftExceptionLogger, which decides whether or not to actuallythrow. -
-
Method Detail
-
assertUnreachable
static void assertUnreachable(String message)
Throw AssertionException with a given message. Use this method surrounded with
{@code * if}
block with assert condition in case you plan to do string concatenation to produce themessage. This logs an assertion with ReactSoftExceptionLogger, which decides whether or not toactually throw.
-
assertCondition
static void assertCondition(boolean condition, String message)
Asserts the given condition, throwing an AssertionException if the condition doesn'thold. This logs an assertion with ReactSoftExceptionLogger, which decides whether or not toactually throw.
-
assertNotNull
static <T> T assertNotNull(@Nullable() T instance)
Asserts that the given Object isn't null, throwing an AssertionException if it was.This logs an assertion with ReactSoftExceptionLogger, which decides whether or not to actuallythrow.
-
-
-
-