Bug 739418 - When reporting a rethrown exception, report the original exception's stack trace. r=blassey a=akeybl
authorChris Peterson <cpeterson@mozilla.com>
Wed, 28 Mar 2012 17:51:02 -0700
changeset 92000 5c0f104db5e976e17015f37c1a9a00a2845d11a6
parent 91999 63c5274f27cb791e1cb05905afccdb1f740d2cea
child 92001 993e301d9bdb47c323b193748ff74a305c8814a5
push idunknown
push userunknown
push dateunknown
reviewersblassey, akeybl
bugs739418
milestone13.0a2
Bug 739418 - When reporting a rethrown exception, report the original exception's stack trace. r=blassey a=akeybl
mobile/android/base/GeckoAppShell.java
--- a/mobile/android/base/GeckoAppShell.java
+++ b/mobile/android/base/GeckoAppShell.java
@@ -145,16 +145,24 @@ public class GeckoAppShell
     public static native void loadNSSLibsNative(String apkName, boolean shouldExtract);
     public static native void onChangeNetworkLinkStatus(String status);
 
     public static void registerGlobalExceptionHandler() {
         Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
             public void uncaughtException(Thread thread, Throwable e) {
                 Log.e(LOGTAG, ">>> REPORTING UNCAUGHT EXCEPTION FROM THREAD "
                               + thread.getId() + " (\"" + thread.getName() + "\")", e);
+
+                // If the uncaught exception was rethrown, walk the exception `cause` chain to find
+                // the original exception so Socorro can correctly collate related crash reports.
+                Throwable cause;
+                while ((cause = e.getCause()) != null) {
+                    e = cause;
+                }
+
                 reportJavaCrash(getStackTraceString(e));
             }
         });
     }
 
     private static String getStackTraceString(Throwable e) {
         StringWriter sw = new StringWriter();
         PrintWriter pw = new PrintWriter(sw);