From ce2e4263bd7a193dc62d92ccdaf70ae6b2fd97fc Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Fri, 14 Jun 2024 16:32:34 -0700 Subject: [PATCH] Make soft exceptions easier to spot in logcat (#44958) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44958 Now, all soft exception methods will have raiseSoftException(...) ## Before ``` BridgelessReact: ReactHost{0}.getOrCreateDestroyTask(): handleHostException(message = "Unable to load script. Make sure you're either running Metro (run 'npx react-native start') or that your bundle 'RNTesterBundle.js' is packaged correctly for release.") ``` ## After ``` BridgelessReact: ReactHost{0}.raiseSoftException(getOrCreateDestroyTask()): handleHostException(message = "Unable to load script. Make sure you're either running Metro (run 'npx react-native start') or that your bundle 'RNTesterBundle.js' is packaged correctly for release.") ``` Changelog: [Internal] Reviewed By: alanleedev Differential Revision: D58593609 fbshipit-source-id: 171a872cd41e4ffe9c2e9654c563a6f3af342ad9 --- .../java/com/facebook/react/runtime/ReactHostImpl.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java index 3977478b313..5f20e18e7d2 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java @@ -903,11 +903,13 @@ public class ReactHostImpl implements ReactHost { setCurrentActivity(null); } - private void raiseSoftException(String method, String message) { - raiseSoftException(method, message, null); + private void raiseSoftException(String callingMethod, String message) { + raiseSoftException(callingMethod, message, null); } - private void raiseSoftException(String method, String message, @Nullable Throwable throwable) { + private void raiseSoftException( + String callingMethod, String message, @Nullable Throwable throwable) { + final String method = "raiseSoftException(" + callingMethod + ")"; log(method, message); if (throwable != null) { ReactSoftExceptionLogger.logSoftException(