OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2013 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 /** | 24 /** |
25 * Singleton helper: install a default unhandled exception handler which shows | 25 * Singleton helper: install a default unhandled exception handler which shows |
26 * an informative dialog and kills the app. Useful for apps whose | 26 * an informative dialog and kills the app. Useful for apps whose |
27 * error-handling consists of throwing RuntimeExceptions. | 27 * error-handling consists of throwing RuntimeExceptions. |
28 * NOTE: almost always more useful to | 28 * NOTE: almost always more useful to |
29 * Thread.setDefaultUncaughtExceptionHandler() rather than | 29 * Thread.setDefaultUncaughtExceptionHandler() rather than |
30 * Thread.setUncaughtExceptionHandler(), to apply to background threads as well. | 30 * Thread.setUncaughtExceptionHandler(), to apply to background threads as well. |
31 */ | 31 */ |
32 public class UnhandledExceptionHandler | 32 public class UnhandledExceptionHandler |
33 implements Thread.UncaughtExceptionHandler { | 33 implements Thread.UncaughtExceptionHandler { |
34 private static final String TAG = "AppRTCDemoActivity"; | 34 private static final String TAG = "AppRTCMobileActivity"; |
35 private final Activity activity; | 35 private final Activity activity; |
36 | 36 |
37 public UnhandledExceptionHandler(final Activity activity) { | 37 public UnhandledExceptionHandler(final Activity activity) { |
38 this.activity = activity; | 38 this.activity = activity; |
39 } | 39 } |
40 | 40 |
41 public void uncaughtException(Thread unusedThread, final Throwable e) { | 41 public void uncaughtException(Thread unusedThread, final Throwable e) { |
42 activity.runOnUiThread(new Runnable() { | 42 activity.runOnUiThread(new Runnable() { |
43 @Override public void run() { | 43 @Override public void run() { |
44 String title = "Fatal error: " + getTopLevelCauseMessage(e); | 44 String title = "Fatal error: " + getTopLevelCauseMessage(e); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 } | 77 } |
78 | 78 |
79 // Returns a human-readable String of the stacktrace in |t|, recursively | 79 // Returns a human-readable String of the stacktrace in |t|, recursively |
80 // through all Causes that led to |t|. | 80 // through all Causes that led to |t|. |
81 private static String getRecursiveStackTrace(Throwable t) { | 81 private static String getRecursiveStackTrace(Throwable t) { |
82 StringWriter writer = new StringWriter(); | 82 StringWriter writer = new StringWriter(); |
83 t.printStackTrace(new PrintWriter(writer)); | 83 t.printStackTrace(new PrintWriter(writer)); |
84 return writer.toString(); | 84 return writer.toString(); |
85 } | 85 } |
86 } | 86 } |
OLD | NEW |