class CustomExceptionHandler
extends java.lang.Object
implements java.lang.Thread.UncaughtExceptionHandler
Thread.setDefaultUncaughtExceptionHandler().
If an uncaught exception is triggered, we store the exception in application specific storage.
No app permissions are required since it uses internal storage.
When the application is restarted, the stored exceptions will be processed (sent to any of the
available services that are configured to receive crash data).
We can't send crash reports immediately, because that would mean doing network requests when
the app is trying to close from the crash.
This object will not override other custom exception handlers. It will chain with them.
Eg: if another crash reporting tool is configured, both custom exception handlers will run
in the reverse order they are initiated.| Modifier and Type | Field and Description |
|---|---|
private android.content.Context |
context |
(package private) java.lang.Thread.UncaughtExceptionHandler |
defaultHandler |
(package private) ExceptionPersister |
exceptionPersister |
private java.util.List<CrashReportingService> |
services |
(package private) Utils |
utils |
private boolean |
wifiOnly |
| Constructor and Description |
|---|
CustomExceptionHandler(android.content.Context context,
java.util.List<CrashReportingService> crashReportingServices,
boolean wifiOnly) |
| Modifier and Type | Method and Description |
|---|---|
(package private) java.lang.String |
getStackTraceString(java.lang.Throwable ex)
Return String version of the stacktrace for a
Throwable. |
(package private) java.util.Map<java.lang.String,StoredException> |
getStoredExceptions()
Get all stored exceptions.
|
(package private) boolean |
isRunning()
Used to check if this class is already running.
|
(package private) void |
sendStoredExceptions()
Iterate through any stored exception files that have not been successfully sent.
|
(package private) void |
start()
Change application exception handler to our own (this class).
|
(package private) void |
stop()
Unregister this class as the default uncaught exception handler.
|
(package private) void |
storeException(java.lang.Thread thread,
java.lang.Throwable ex)
Create a
StoredException object for the passed in Thread and Throwable. |
void |
uncaughtException(java.lang.Thread thread,
java.lang.Throwable ex)
Handle uncaught exceptions.
|
private android.content.Context context
Utils utils
private java.util.List<CrashReportingService> services
private boolean wifiOnly
ExceptionPersister exceptionPersister
java.lang.Thread.UncaughtExceptionHandler defaultHandler
CustomExceptionHandler(android.content.Context context,
java.util.List<CrashReportingService> crashReportingServices,
boolean wifiOnly)
void start()
void stop()
public void uncaughtException(java.lang.Thread thread,
java.lang.Throwable ex)
uncaughtException in interface java.lang.Thread.UncaughtExceptionHandlervoid storeException(java.lang.Thread thread,
java.lang.Throwable ex)
StoredException object for the passed in Thread and Throwable.
Use our ExceptionPersister class to store this data on the device.thread - Thread that generated the exceptionex - Exception data.java.lang.String getStackTraceString(java.lang.Throwable ex)
Throwable.ex - Throwable to convert to a String.void sendStoredExceptions()
java.util.Map<java.lang.String,StoredException> getStoredExceptions()
boolean isRunning()