diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactSoftExceptionLogger.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactSoftExceptionLogger.java index bf4f7348588..a33590a83d0 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactSoftExceptionLogger.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactSoftExceptionLogger.java @@ -50,4 +50,11 @@ public class ReactSoftExceptionLogger { FLog.e(category, "Unhandled SoftException", cause); } } + + @DoNotStrip + // For use from within the C++ JReactSoftExceptionLogger + private static void logNoThrowSoftExceptionWithMessage( + final String category, final String message) { + logSoftException(category, new ReactNoCrashSoftException(message)); + } } diff --git a/ReactAndroid/src/main/jni/react/jni/JReactSoftExceptionLogger.cpp b/ReactAndroid/src/main/jni/react/jni/JReactSoftExceptionLogger.cpp new file mode 100644 index 00000000000..788de6f99ab --- /dev/null +++ b/ReactAndroid/src/main/jni/react/jni/JReactSoftExceptionLogger.cpp @@ -0,0 +1,21 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#include "JReactSoftExceptionLogger.h" + +using namespace facebook::react; + +void JReactSoftExceptionLogger::logNoThrowSoftExceptionWithMessage( + std::string tag, + std::string message) { + static const auto logNoThrowSoftExceptionWithMessage = + javaClassStatic() + ->getStaticMethod( + "logNoThrowSoftExceptionWithMessage"); + + return logNoThrowSoftExceptionWithMessage(javaClassStatic(), tag, message); +} diff --git a/ReactAndroid/src/main/jni/react/jni/JReactSoftExceptionLogger.h b/ReactAndroid/src/main/jni/react/jni/JReactSoftExceptionLogger.h new file mode 100644 index 00000000000..6a91ec709af --- /dev/null +++ b/ReactAndroid/src/main/jni/react/jni/JReactSoftExceptionLogger.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +class JReactSoftExceptionLogger + : public jni::JavaClass { + public: + static constexpr const char *kJavaDescriptor = + "Lcom/facebook/react/bridge/ReactSoftExceptionLogger;"; + + static void logNoThrowSoftExceptionWithMessage( + std::string tag, + std::string message); +}; + +} // namespace react +} // namespace facebook