From aa2c1a6000dccde136ef9e644d6e7cd4bdd1a723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliv=C3=A9r=20Falvai?= Date: Mon, 17 Aug 2026 10:55:36 +0200 Subject: [PATCH] Android: log full exceptions instead of just their message Several catch blocks called CodePushUtils.log(String) with only e.getMessage(), even though the exception object was already in hand. That silently drops the stack trace from logcat, since only CodePushUtils.log(Throwable) actually prints it (via Log.e). Switch those sites to log the Throwable itself, preserving the original context in a wrapping message where one existed. --- .../main/java/com/microsoft/codepush/react/CodePush.java | 2 +- .../com/microsoft/codepush/react/CodePushNativeModule.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java b/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java index 81369d88..ceafd545 100644 --- a/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +++ b/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java @@ -244,7 +244,7 @@ public String getJSBundleFileInternal(String assetsBundleFileName) { packageFilePath = mUpdateManager.getCurrentPackageBundlePath(this.mAssetsBundleFileName); } catch (CodePushMalformedDataException e) { // We need to recover the app in case 'codepush.json' is corrupted - CodePushUtils.log(e.getMessage()); + CodePushUtils.log(e); clearUpdates(); } diff --git a/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java b/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java index 604e60e3..3add4f6e 100644 --- a/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +++ b/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java @@ -211,7 +211,7 @@ private void loadBundle() { CodePushUtils.log(new Exception("ClassCastException trying to get/use ReactHostDelegate. Skipping reflection call to setJSBundle. This is expected for Expo.", cce)); }catch (Exception e) { // Catch any unexpected errors from the attempt to call setJSBundle, e.g., if getReactHostDelegate itself fails - CodePushUtils.log("Exception during the reflective setJSBundle block: " + e.getMessage()); + CodePushUtils.log(new Exception("Exception during the reflective setJSBundle block", e)); } // #3) Get the context creation method @@ -226,7 +226,7 @@ private void loadBundle() { } catch (Exception e) { // reflection logic failed somewhere so fall back to restarting the Activity (if it exists) - CodePushUtils.log("Failed to load the bundle, falling back to restarting the Activity (if it exists). " + e.getMessage()); + CodePushUtils.log(new Exception("Failed to load the bundle, falling back to restarting the Activity (if it exists)", e)); loadBundleLegacy(); } } @@ -486,7 +486,7 @@ protected Void doInBackground(Void... params) { } } catch (CodePushMalformedDataException e) { // We need to recover the app in case 'codepush.json' is corrupted - CodePushUtils.log(e.getMessage()); + CodePushUtils.log(e); clearUpdates(); promise.resolve(null); } catch(CodePushUnknownException e) {